Truncate files to a given size
migeyel opened this issue ยท 0 comments
The newly implemented r+b
support allows for implementing advanced random-access disk data structures like databases and virtual disk images. However, as of right now, these files can only grow in size. Shrinking a file requires copying its contents over into a separate file and deleting the old one. If the disk is full, there's not much you can do about it.
Truncating file contents is the common solution to this and is already implemented in SeekableByteChannel.truncate
. Incorporating it would require adding a new method to write file handles, as well as adjusting the filesystem quota counts around the new operation. Shouldn't be too much of a hassle.
I don't see any compatibility issues besides the fact that fs overrides will not have the method implemented by default, but this can also be said about r+b
support.