Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Truncating a file?

0 views
Skip to first unread message

Michael Berg

unread,
Jan 26, 1994, 1:47:29 PM1/26/94
to
In a message of 25 Jan 94 James Cooper wrote to All:

JC> No, I wouldn't trust it. The FILE* has pointers, buffers, etc.
JC> Suppose you do this, truncate the file, do the fseek(), and it tries to
JC> flush a write buffer at offset 3000 (when you've just truncated the file
JC> to 100 bytes...) FILESYSTEM CORRUPTION!

Simply seeking to a nonexisting position in a file does not cause the filesystem to corrupt (thank God... :-)

JC> No, the safest way would be to fclose() the file, Open() it, truncate
JC> the size, Close() it, then fopen() it again.

That would require the name of the file to be passed to the truncation function as well.

JC> Of course, the best way of all would be to use the FOpen(), etc. calls
JC> that exist in 2.0+ of the OS, and avoid the issue altogether. This
JC> does make the program not work under 1.3 and earlier, but...

There is no such beast as an FOpen(). You use Open() to open any AmigaDOS file, even in buffered mode ;-)
__
__/// Sincerely | PowerData & PowerCache Development
\\X/ Michael | Internet: mb...@scala.ping.dk

... If a straight line fit is required, obtain only two data points.

0 new messages