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
623 stars 113 forks source link

Problems with paths longer than 259 characters #45

Closed fabri9532 closed 11 months ago

fabri9532 commented 4 years ago

I have this path on my hard disk (without quotes): "C:\Cartella Condivisa\DITTE STUDIO BELLON SRL\CONTABILITA' ORDINARIE\GENTOREMONA SRL IN LIQUIDAZIONE (CESSATA 01.04.2019)\BILANCIO FINALE DI LIQUIDAZIONE\BILANCIO FINALE DI LIQUIDAZIONE\"

In the final folder I have the following files (without quotes): "Delega Gentono Fabio in favore della moglie Torramini Silvana Claudia.as" "Delega Gentono Fabio in favore della moglie Torramini Silvana Claudia.pdf" "Delega Gentono Fabio in favore della moglie Torramini Silvana Claudia.pdf.p7m"

I use this code: bit7z::Bit7zLibrary lib{ L"7z.dll" };

    bit7z::BitCompressor compressor{ lib, bit7z::BitFormat::SevenZip };

    compressor.setCompressionMethod(bit7z::BitCompressionMethod::Lzma2);
    compressor.setCompressionLevel(bit7z::BitCompressionLevel::FAST);

    compressor.compressDirectory(L"C:\\Cartella condivisa", L"D:\\Output.7z");

Only the first file "Delega Gentono Fabio in favore della moglie Torramini Silvana Claudia.as" is present in the "Output.7z" and no error occurs.

I use 7zip Dll v19.00, Bit7z v3.1.1 and Windows 10 x64 v1909 I have tested with "Windows 10 long path name" enabled and disabled: same result.

I have 7zip installed (v19.00) and if I compress "Cartella Condivisa", all the files are compressed (also if "Windows 10 long path name" is disabled).

rikyoz commented 4 years ago

I use 7zip Dll v19.00, Bit7z v3.1.1 and Windows 10 x64 v1909 I have tested with "Windows 10 long path name" enabled and disabled: same result.

This is really weird. Have you tried to prepend \\?\ to the path passed to BitCompressor::compressDirectory, e.g., L"\\?\C:\\Cartella condivisa"?

fabri9532 commented 4 years ago

If I prepend "\\?\" it works properly. If this behavior is normal, I think, if I don't prepend "\\? \" and there is a paths longer than 259 characters, bit7z should throw an exception or alternatively add note in the documentation to check the length externally to bit7z.

Thanks, Fabrizio.

rikyoz commented 11 months ago

Added the option BIT7Z_AUTO_PREFIX_LONG_PATHS for automatically prepend \\?\ to paths in v4.0.0.