T
Timothy Madden
[cross-posted to comp.lang.c, comp.lang.c++]
Hello
I see there is now why to truncate a file (in C or C++)
and that I have to use platform-specific functions for
truncating files.
Anyone knows why ? I mean C/C++ evolved over many years now,
and still, people making _the_ standards never decided to
include such a function. Even in POSIX it was included only
in recent versions, mostly not fully supported yet.
Why is that ? They must think there is something wrong with it,
or that there are better ways to do it.
I mean I want to write a portable application, I keep
application data in a file, at some point the user
deletes something from the data my program presents
to him/her, and now I delete some data from the data file
and want to shrink the file. Like a database system,
after dropping some records or tables and compacting
(or vacuum) the database. That is a good example
of when a programmer legally needs to truncate a file.
Copying only remaining data to a new file that will then
replace the old one is not a solution for a large database,
and leaving the empty space in the file is also not a
solution for large files.
Thank you,
Timothy Madden
Hello
I see there is now why to truncate a file (in C or C++)
and that I have to use platform-specific functions for
truncating files.
Anyone knows why ? I mean C/C++ evolved over many years now,
and still, people making _the_ standards never decided to
include such a function. Even in POSIX it was included only
in recent versions, mostly not fully supported yet.
Why is that ? They must think there is something wrong with it,
or that there are better ways to do it.
I mean I want to write a portable application, I keep
application data in a file, at some point the user
deletes something from the data my program presents
to him/her, and now I delete some data from the data file
and want to shrink the file. Like a database system,
after dropping some records or tables and compacting
(or vacuum) the database. That is a good example
of when a programmer legally needs to truncate a file.
Copying only remaining data to a new file that will then
replace the old one is not a solution for a large database,
and leaving the empty space in the file is also not a
solution for large files.
Thank you,
Timothy Madden