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

Implement writing to archives #78

Merged
merged 40 commits into from
Dec 22, 2023
Merged

Conversation

white-axe
Copy link
Collaborator

Description
I've implemented writing to files, renaming files and creating and removing files and directories inside of archives. The performance characteristics are predictably quite poor so I'm still making an archive manager that will use these features more efficiently.

As an optimization, when a file within an archive is written to and the length of the file has changed, the file is moved to the end of the archive so that subsequent writes to the same file will take less time. If the file length hasn't changed, the file will be written to in-place.

This pull request also comes with additional features for the host (native and web) filesystems:

  • They are now capable of creating temporary files, with the web filesystem backing these using the Origin Private File System for better performance and so that no user permission is required. This is useful because some of the write operations for archives need to move around lots of data within the archive and the most efficient way to do that is reading the entire archive somewhere and then writing the entire thing back. I don't think it's a good idea to read the entire archive into memory!
  • The file trait has a new required method, set_len, for extending and truncating files, because writing to an archive may reduce its size.

Testing
Try saving to an RPG Maker XP project without archives first just to make sure saving to this project normally works. Make sure to modify one of the maps by drawing tiles or moving around events, otherwise no files will be written!

Once that is confirmed to work, create an archive containing the Data and Graphics directories in the project using RPG Maker XP or some third-party tool. Move the archive into the root directory of the project and delete the original Data and Graphics directories. Then try loading and saving again (after modifying the project).

Checklist

  • Run cargo fmt.
  • Run cargo clippy. If applicable, add:
    • --target wasm32-unknown-unknown
  • Run cargo build --release
  • If applicable, run trunk build --release

Blame my language server for whatever this is.
The list filesystem should only create files in filesystems where the
parent directory of the file exists.
@white-axe white-axe requested a review from a team as a code owner December 21, 2023 06:34
@white-axe white-axe added the enhancement New feature or request label Dec 21, 2023
@white-axe white-axe merged commit a7cd8c4 into Astrabit-ST:dev Dec 22, 2023
5 checks passed
@white-axe white-axe deleted the archive-write branch December 22, 2023 17:51
@melody-rs melody-rs mentioned this pull request Dec 24, 2023
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants