-
-
Notifications
You must be signed in to change notification settings - Fork 117
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
Extract specific file to buffer #32
Comments
I can see the feature is there, the problem is it does not detect the archive type.
|
It is not working, it expects I input the path to the archive, not the path to the file. |
Unfortunately, at the moment extracting a single file to a buffer by matching its name/path is not available: extraction by matching is supported only when the output target is the filesystem. Implementing such functionality should not take much time, however it would potentially introduce redundancies in the code and avoiding them would take some time for reasoning; moreover, it would introduce also inconsistencies in the API which must be addressed!
Anyway, with the current version of bit7z there is a workaround: you can use the BitExtractor::extract(...) method, to which you can pass, as third parameter, the index (in the archive) of the file you need (you can get it using BitArchiveInfo if you don't already know it a priori). const auto archive_name = L"archive.7z";
const auto file_path = L"path/to/another/file.txt"; // The path of the file you want to extract inside the archive
vector< byte_t > buffer;
BitArchiveInfo arc{ lib, archive_name, BitFormat::SevenZip };
auto arc_items = arc.items();
for ( auto& item : arc_items ) {
if ( item.path() == file_path ) {
// We have found the file we want to extract!
BitExtractor extractor{ lib, BitFormat::SevenZip };
extractor.extract( archive_name, buffer, item.index() );
break;
}
} |
Thanks for taking time to respond and also for the info. I will try this method instead. |
You're welcome! |
Could we possibly get the ability to use pre-allocated C style buffers (eg: void *buf)? Trying to use the library to load game files, but allocation of a new buffer and then copying is forcing me to double the ram usage of large files (700mb) on a 32 bit process, and running out of memory. |
Supporting C style buffers would require really many changes in the internal code of bit7z, which extensively uses |
Is your feature request related to a problem? Please describe.
No
Describe the solution you'd like
I can see that we can extract specific files by matching paths. However I'd like to extract a specific file to buffer.
I'm not sure how long it will take to implement this since my app needs this feature to extract webpages into a buffer.
Additional context (optional)
Something like this
extractor.extract( L"path/to/another/file.txt", buffer );
The text was updated successfully, but these errors were encountered: