Saynatkari wrote:
> I think #truncate simply memset()s the buffer but it does not
> change the position of the file pointer, so you would probably
> need to #seek 0, as well.

Very odd.  From the man page:

http://www.opengroup.org/onlinepubs/009695399/functions/truncate.html

truncate - truncate a file to a specified length

The truncate() function shall cause the regular file named by path to 
have a size which shall be equal to length bytes.

If the file previously was larger than length, the extra data is 
discarded. If the file was previously shorter than length, its size is 
increased, and the extended area appears as if it were zero-filled.

And on Linux:

http://linux.com.hk/PenguinWeb/manpage.jsp?name=truncate&section=2


Cheers,
--binkley