file_5.py 514 B

1234567891011121314
  1. def truncae(self, pgno, maximumSize):
  2. buffer = [0]*maximumSize
  3. limit = 1024
  4. count = 0
  5. # opens the file for read and append
  6. f = open("F:/labOS/funner.dat", "r+")
  7. if f:
  8. # moves the pointer
  9. f.seek(pgno*1024+maximumSize)
  10. # instead of trimming the file it actually overwrites the file with empty spaces
  11. for i in range(limit):
  12. buffer[count] = " "
  13. f.write(str(buffer[count]))
  14. f.close()