Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Truncate files to a given size #1730

Open
migeyel opened this issue Feb 20, 2024 · 0 comments
Open

Truncate files to a given size #1730

migeyel opened this issue Feb 20, 2024 · 0 comments
Labels
area-Core This affects CC's core (the Lua runtime, APIs, computer internals). enhancement An extension of a feature or a new feature.

Comments

@migeyel
Copy link

migeyel commented Feb 20, 2024

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.

@migeyel migeyel added the enhancement An extension of a feature or a new feature. label Feb 20, 2024
@SquidDev SquidDev added the area-Core This affects CC's core (the Lua runtime, APIs, computer internals). label Feb 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-Core This affects CC's core (the Lua runtime, APIs, computer internals). enhancement An extension of a feature or a new feature.
Projects
None yet
Development

No branches or pull requests

2 participants