You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I think your code example is missing the line where you actually call the extract method of BitFileExtractor.
Anyway, your problem is that the files in the tar/zip archive have an invalid character in their names, specifically the character :, hence the error. On Windows, files and folders cannot contain such a character (as explained here).
You can enable the bit7z option BIT7Z_PATH_SANITIZATION: in this case bit7z will take care of replacing all invalid characters in the file names with the underscore character _.
Also, since the paths of the files are absolute paths, bit7z will try to extract them to the disk root directory (e.g., C:\) rather than to the output path you pass to the method.
This is likely to fail unless you run the program with admin privileges.
You can avoid the latter problem by calling extractor.setRetainDirectories( false ); before extracting the archive.
bit7z version
4.0.x, 3.2.x
Compilation options
BIT7Z_AUTO_FORMAT
7-zip version
v23.01
7-zip shared library used
7z.dll / 7z.so
Compilers
MSVC
Compiler versions
vs2022
Architecture
x86
Operating system
Windows
Operating system versions
No response
Bug description
The read content is as follows:
\颜色分类:奶茶色;镜片折射率:镜框+【微薄】1.56防蓝光防辐射镜片(适合0-300度)_椰妇_2023年08月05日_初评.txt
\颜色分类:奶茶色;镜片折射率:镜框+【微薄】1.56防蓝光防辐射镜片(适合0-300度)_椰妇_2023年08月05日_初评图片_1.jpg
\颜色分类:奶茶色;镜片折射率:镜框+【微薄】1.56防蓝光防辐射镜片(适合0-300度)_椰妇_2023年08月05日_初评图片_2.jpg
\颜色分类:奶茶色;镜片折射率:镜框+【微薄】1.56防蓝光防辐射镜片(适合0-300度)_椰妇_2023年08月05日_初评图片_3.jpg
\颜色分类:奶茶色;镜片折射率:镜框+【微薄】1.56防蓝光防辐射镜片(适合0-300度)_椰***妇_2023年08月05日_初评图片_4.jpg
BitFileExtractor extractor{ lib, BitFormat::Auto };
Exception: Failed to open the output file: 文件名、目录名或卷标语法不正确。
Steps to reproduce
bool UnzipTest(const wstring& zipFile, const wstring& strOutDir)
{
try
{
Bit7zLibrary lib;
BitFileExtractor extractor{ lib, BitFormat::Auto };
}
catch (const bit7z::BitException& ex)
{
auto msg = ex.what();
auto code = ex.nativeCode();
auto posixCode = ex.posixCode();
return false;
}
return true;
}
UnzipTest(L"D:\tar\123.tar", L"C:\tar\123");
Expected behavior
Correctly UnZip files Suc
The 123.rar file extracted from 123.zip in the attachment is the file I tested
123.zip
Relevant compilation output
No response
Code of Conduct
The text was updated successfully, but these errors were encountered: