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

assetsys: Add assetsys_mount_data() to mount data buffers #61

Merged
merged 7 commits into from
Sep 5, 2023

Conversation

RobLoach
Copy link
Contributor

@RobLoach RobLoach commented Sep 3, 2023

This change attempts to tackle #53 and adds a assetsys_mount_data() function to mount data from an archive data buffer. This paves the path to allow disabling STDIO, and cases in which the target already has the file loaded into memory.

assetsys_error_t assetsys_mount_data( assetsys_t* sys, void const* data, size_t size, char const* mount_as )

It splits the assetsys_mount() into two different internal functions to save on code duplication. These functions may or may not be named correctly:

  • assetsys_internal_create_mount(): Prepares a new mount for the assetsys instance
  • assetsys_internal_mount_files(): Iterates through the mount system and indexes the files

Would love your thoughts on this. Eventually, I'd like to be able to define MINIZ_NO_STDIO to skip cases where STDIO isn't needed.

This change attempts to tackle mattiasgustavsson#53 and adds a `assetsys_mount_data()` function to mount data from an archive data buffer. This paves the path to allow disabling STDIO, and cases in which the target already has the file loaded into memory.

It splits the `assetsys_mount()` into two different internal functions to save on code duplication. These functions may or may not be named correctly:
- `assetsys_internal_create_mount()`: Prepares a new mount for the assetsys instance
- `assetsys_internal_mount_zip(): Iterates through the mount system and indexes the files
@mattiasgustavsson
Copy link
Owner

I think that looks great! Only thing is, I am not sure about, is the name assetsys_mount_data - it's just that in the context of assetsys, the term data is almost overused as is, in names and documentation :P I think it would be better to call the function assetsys_mount_from_memory in a similar naming style as stb_image.h, which has stbi_load and stbi_load_from_memory iirc. It's no big thing though, and I am not dead set on it. What do you think?

@RobLoach
Copy link
Contributor Author

RobLoach commented Sep 5, 2023

  • Renamed the function to assetsys_mount_from_memory
  • Added a test case for it
  • Also tried compiling with MINIZ_NO_STDIO, and it seems to function properly

assetsys.h Outdated Show resolved Hide resolved
@mattiasgustavsson
Copy link
Owner

Oh, I almost forgot, there's a "contributors" section near the end of the file, just before the license. Maybe add your name there (only if you want to of course). But yeah, looks good to go!

@mattiasgustavsson mattiasgustavsson merged commit 774d040 into mattiasgustavsson:main Sep 5, 2023
7 checks passed
@mattiasgustavsson
Copy link
Owner

Great! Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants