Closed kenkit closed 2 years ago
I can see the feature is there, the problem is it does not detect the archive type.
Folders count: 0
Files count: 3
Size: 13551341
Packed size: 13376716
Archive items
Item index: 0
Name: J110F_twrp.img.tar
Extension: tar
Path: J110F_twrp.img.tar
IsDir: 0
Size: 9533440
Packed size: 9359154
Item index: 1
Name: UPDATE-SuperSU-v2.46.zip
Extension: zip
Path: UPDATE-SuperSU-v2.46.zip
IsDir: 0
Size: 4017098
Packed size: 4017098
Item index: 2
Name: Password.txt
Extension: txt
Path: Password.txt
IsDir: 0
Size: 803
Packed size: 464
Cannot detect the format of the file <---After listing the archive I extract to buffer
It is not working, it expects I input the path to the archive, not the path to the file. So I think this is a valid feature request.
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 );
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!
It is not working, it expects I input the path to the archive, not the path to the file. So I think this is a valid feature request.
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). For example:
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.
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 std::vector
.
Anyway, for the next version I will evaluate how to support it, but it won't be anytime soon (due to other commitments).
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