J
jkherciueh
Hi,
I am writing a container template file_of< POD > that should resemble
std::vector< T > as closely as feasible given that the container actually
interfaces to an underlying file on disk. E.g., insertion can take
place *only* at the end. Nonetheless, I would like to implement the
pop_back() method. So I need to cut off the tail of a file, represented
as std::basic_filebuf< char >, and keep an initial segment.
Is there a standard/protable way of doing this. Currently, I use a hack
invoking the POSIX ftruncate system call. I understand that this is not
portable.
I had a look at the draft copies of the standard freely available on the
internet, but the methods in basic_filebuf seem not to allow for this.
The only way that I see is to copy the initial part that I want to keep
to a new file and ditch the old one. But that seems to be inefficient.
Thanks for your consideration
Kai-Uwe Bux
I am writing a container template file_of< POD > that should resemble
std::vector< T > as closely as feasible given that the container actually
interfaces to an underlying file on disk. E.g., insertion can take
place *only* at the end. Nonetheless, I would like to implement the
pop_back() method. So I need to cut off the tail of a file, represented
as std::basic_filebuf< char >, and keep an initial segment.
Is there a standard/protable way of doing this. Currently, I use a hack
invoking the POSIX ftruncate system call. I understand that this is not
portable.
I had a look at the draft copies of the standard freely available on the
internet, but the methods in basic_filebuf seem not to allow for this.
The only way that I see is to copy the initial part that I want to keep
to a new file and ditch the old one. But that seems to be inefficient.
Thanks for your consideration
Kai-Uwe Bux