Click to See Complete Forum and Search --> : Can a eof marker be moved backwards?
Stric
08-26-2002, 09:27 PM
I am using fstream and opening a binary file for input and output. I want
to remove data from the file then shift all the remaining data back over
the free area. Since the file would be smaller I need to move the eof marker
backwards. Can this be done? Or do I have to create a new file.
ralph
08-27-2002, 06:08 AM
"Stric" <cgftp@tampabay.rr.com> wrote:
>
>I am using fstream and opening a binary file for input and output. I want
>to remove data from the file then shift all the remaining data back over
>the free area. Since the file would be smaller I need to move the eof marker
>backwards. Can this be done? Or do I have to create a new file.
Not really. When you work with File stream I/O at the application level you
are not dealing with the file per se, but with file buffers. So you can 'play'
with these buffers all you want, but getting the changes back is another
story.
While it may seem like "more work", opening another file and writing the
changes to it is the easier and safest way to go.
Danny Kalev
08-27-2002, 07:29 AM
Using the standard fstream files, there's no other choice but to create
a new file, delete the original file and rename the new file. The
problem is that different OS's use different disk allocation schemes so
there's no way to guarantee that an eof in the middle of the file will
force the file system to treat the data past the eof as free disk space.
Danny
Stric wrote:
>
> I am using fstream and opening a binary file for input and output. I want
> to remove data from the file then shift all the remaining data back over
> the free area. Since the file would be smaller I need to move the eof marker
> backwards. Can this be done? Or do I have to create a new file.
devx.com
Copyright Internet.com Inc. All Rights Reserved