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

Request: Open CAB without fopen #111

Closed
bwrsandman opened this issue Feb 9, 2021 · 9 comments
Closed

Request: Open CAB without fopen #111

bwrsandman opened this issue Feb 9, 2021 · 9 comments

Comments

@bwrsandman
Copy link
Contributor

bwrsandman commented Feb 9, 2021

Would it be feasible to add a function to the library that allows opening a CAB file from memory such as this?

Unshield* unshield_open_from_buffer(const char* filename, const void* buffer, size_t buffer_size);

This would allow the piping the contents of cab files from zlib or libcdio without doing a round trip to the filesystem.

@twogood
Copy link
Owner

twogood commented Feb 9, 2021

I'm not sure that would work, as both the .cab and the .hdr files are needed at the same time but only the .cab file need to be specified on the command line and the .hdr file is found by changing file suffix. If the logic for opening with different suffix could be overridden you could probably send in /dev/fd/X as path for .cab and .hdr.

@twogood
Copy link
Owner

twogood commented Feb 9, 2021

There is also the support for multiple .cab files. And the code does ftell and fseek to find out the size of files.

@bwrsandman
Copy link
Contributor Author

bwrsandman commented Feb 9, 2021

Perhaps an interface where I can supply my own io callbacks instead of using fopen, fseek, ftell?

I've seen this done with minizip's unzOpen2
https://github.com/luvit/zlib/blob/master/contrib/minizip/ioapi.h#L172
https://github.com/luvit/zlib/blob/master/contrib/minizip/unzip.h#L184

This should be enough to support hdr files and multiple CAB files as the callbacks would require my implementation to extract those extra files from libcdio.

@twogood
Copy link
Owner

twogood commented Feb 9, 2021

That's a neat abstraction! Quite a makeover to implement though.

@bwrsandman bwrsandman changed the title Request: Open CAB from buffer Request: Open CAB without fopen Feb 9, 2021
@bwrsandman
Copy link
Contributor Author

bwrsandman commented Feb 10, 2021

Posted a proposed implementation of io callbacks.
I was able to list contents of a cab file inside of a cue/bin pair read with libcdio:
https://github.com/bwrsandman/unshield/blob/io_callbacks_example/src/isocab.c#L80-L366

@bwrsandman
Copy link
Contributor Author

Any possible update on this?

Virtual filesystem support would benefit usecases where file system is restricted or slow: i.e. android, web assembly, read-only file systems.

@bwrsandman
Copy link
Contributor Author

This has been delivered in #112

Any idea when a version will be released with this change?

@twogood
Copy link
Owner

twogood commented Jan 3, 2024

This has been delivered in #112

Any idea when a version will be released with this change?

I guess I can make a new release anytime, and maybe i should merge #180 first?

@bwrsandman
Copy link
Contributor Author

That's right but no immediate rush.

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

No branches or pull requests

2 participants