rikyoz / bit7z

A C++ static library offering a clean and simple interface to the 7-zip shared libraries.
https://rikyoz.github.io/bit7z
Mozilla Public License 2.0
634 stars 116 forks source link

keep file hierarchy #97

Closed wandth closed 2 years ago

wandth commented 2 years ago

how could I keep file hierarchy when I zip some files

Bit7zLibrary lib{L"E:/__daily/7z.dll"};
lib.setLargePageMode();

std::shared_ptr<BitCompressor> compressor = std::make_shared<BitCompressor>(lib, BitFormat::Zip);

uint64_t total_size = 0;
compressor->setTotalCallback([&total_size](uint64_t _total_size) {
    total_size = _total_size;
});
compressor->setProgressCallback([&total_size](uint64_t _zipped_size) {
    std::cout << "Progress: " << double(_zipped_size) / double(total_size) << std::endl;
});

compressor->setVolumeSize(1024 * 1024 * 1024);

std::vector<std::wstring> files = {
        L"E:/__daily/f.usda",
        L"E:/__daily/aa/f.usda"
};

compressor->compressFiles(files, L"E:/__daily/zip/output_archive.zip");

the file path is

wandth commented 2 years ago

I found code in issue

std::map<std::wstring, std::wstring> files = {
        {L"E:/__daily/f.usda" , L"E/__daily/f.usda\"f.usda"},
            {L"E:/__daily/aa/f.usda",  L"E/aa/f.usda"},
};
compressor->compress(files, L"E:/__daily/zip/output_archive.zip");