Reputation: 2380
If I do a seekp past the end of a file and then a write what happens? What I would like to happen is that the file would automatically be extended to the size of the seekp location. If so, does it also fill in the space between the old end of file and the new location by writing anything to the disk or is the space just allocated.
However, if it does not extend the file, how could I accomplish fairly efficiently?
Upvotes: 2
Views: 693
Reputation: 500357
It is perfectly acceptable to seekp()
past the end of file and then write. The file would indeed be extended.
Whether or not there would be disk space allocated for the hole depends on the filesystem. Some filesystems (e.g. ext3
) support sparse files, some don't.
Upvotes: 2