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
602 stars 110 forks source link

[Feature Request]: Can we preview files layer by layer like zlib #158

Open psvajaz opened 11 months ago

psvajaz commented 11 months ago

Feature description

Can we preview files layer by layer like zlib

Additional context

No response

Code of Conduct

rikyoz commented 11 months ago

Do you mean previewing the content of the tarball inside tar.bz2 or tar.gz archives without having to extract the outer archive? Unfortunately, bit7z doesn't support this feature at the moment. 7-zip doesn't provide such functionality out-of-the-box, and it's not easy to implement it, but I'll definitely work on it for the v4.1.

psvajaz commented 11 months ago

I'm not just talking about the preview in tar.bz2 format, but I hope that any 7z supported file can work like zlib. I pass in the path of a compressed package file, and bit7z returns all the files and folders under this path, displaying the compressed and uncompressed sizes of the folders. This function is similar to the preview mode of 7zFM.

My current preview function is to obtain the file size of the compressed package through the BitArchiveReader function, and use recursive loops to count the compressed and uncompressed sizes of all files in each folder subset, which is relatively slow in efficiency.

It was found in the development that the compressed package in some formats only provides the complete path of the files in the compressed package, and does not contain directory information. It is necessary to run traversal logic to determine whether directory information exists in the file list after obtaining the file list through BitArchiveReader. If not, it is necessary to create directory information in the cache list and recursively calculate the file size. Only in this way can it be provided to the UI for display and processing.

rikyoz commented 11 months ago

I see. This is a different feature than the one I described before.

At the moment, bit7z provides only the item metadata that the 7-zip DLLs offer, nothing more.

I guess the 7zFM GUI performs further processing for calculating each folder's size when such metadata is not already available in the archive format. I don't know how the GUI implements this; I need to investigate this.

Also, in some cases, the size metadata is not provided even by 7zFM, e.g., when the archive uses solid compression.

Anyway, I'll evaluate how to provide such information, considering that this should not add any relevant overhead for the library users not interested in calculating/retrieving such information.