Set End Of File

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by horst.

Shouldn't there be a built-in function to set the end of file
(i.e. truncate an existing file)?

API:
SetEndOfFile_(UseFile(file#))


Horst
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Amiga5k.

Hmm... You could set the EOF by changing the length of the file in various ways (rewrite it). EOF, AFAIK, is an OS function that returns true if it is, indeed, the end of the file. It wouldn't make sense to have an EOF somewhere in the middle [:/]

Russell

***Commodore 64 - Over one million cycles per second, 16 vibrant colors, 3 incredible audio channels and 38,911 Basic Bytes Free! Who could ask for anything more?***
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by freak.

What he wants is make the file shorter, without rewriting it. You can make the file longer, if you write something behind it's end, but there is currently no function for the opposite.

That is what the SetEndOfFile_() API does, it set's the End of the File to the current position (set by FileSeek() for example), so everything after the current position will be deleeted.

Timo
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Amiga5k.

Ah, my mistake The only thing I would say about this command is "Use with extreme caution!"

Russell

***Commodore 64 - Over one million cycles per second, 16 vibrant colors, 3 incredible audio channels and 38,911 Basic Bytes Free! Who could ask for anything more?***
Post Reply