File write may NOT truncate the rest of file?

Post

Posted
Rating:
#1 (In Topic #1278)
Regular
sergioabreu is in the usergroup ‘Regular’
 I am not sure if is my fault or not on writing content to existing file:
If I do a write with an smaller content, the file is keeping the extra "piece".
If I delete (kill) and create, goes right.

Is there a trick to writing correctly (and truncating the rest if necessary) ?

Example I have a file with 1000 bytes, and I write 995, the file doesn't get truncated, keeps 1000 bytes (5 trash bytes)

Thanks
Online now: No Back to the top

Post

Posted
Rating:
#2
Avatar
Regular
thatbruce is in the usergroup ‘Regular’
Its all explained in the wiki: /lang/open - Gambas Documentation

Online now: No Back to the top

Post

Posted
Rating:
#3
Guru
BruceSteers is in the usergroup ‘Guru’
Do you use the Create keyword with Open to clear the existing content?

Code (gambas)

  1. hFile = OPEN "/path/to/file" FOR READ WRITE CREATE
  2.  
Online now: No Back to the top

Post

Posted
Rating:
#4
Regular
sergioabreu is in the usergroup ‘Regular’
 My problem always is the long usage of other languages.

In them, WRITE operation usually included "truncating", meaning almost an "overwrite".

CREATE seems to be to use only if the file didn't exist.  Now I understand.

Thanks for all
Online now: No Back to the top
1 guest and 0 members have just viewed this.