libarchive / libarchive

Multi-format archive and compression library

Home Page:http://www.libarchive.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[STABLE 3.7.3] Wiki - Examples - A Complete Extractor, cannot extract .7z.001 files

LukeSkyD opened this issue · comments

Hello!
I'm writing a qt cpp project which build with cmake.

I can extract thanks to that code .zip and .7z files no problem.

There is no way to extract .7z.001 files
I've downloaded all the .002 and .003 files, they work great with 7zip and other archive managers.

I tried calling the extract function with the full absolute path, removing .001, removing .7z.001, making some cpp code
`// Check if the file is multi-volume (ends with .001)
if (strstr(filename, ".001") != NULL) {
char multi_volume_pattern[1024];
strncpy(multi_volume_pattern, filename, strlen(filename) - 3); // Remove .001 from the end
multi_volume_pattern[strlen(filename) - 4] = '\0'; // Null-terminate the string

    archive_read_support_format_raw(a);
    r = archive_read_support_filter_none(a);
    if (r != ARCHIVE_OK)
        exit(1);
    r = archive_read_open_filename(a, multi_volume_pattern, 10240);
    if (r != ARCHIVE_OK)
        exit(1);
} else {
    r = archive_read_open_filename(a, filename, 10240);
    if (r != ARCHIVE_OK)
        exit(1);
}`

But the r variable here
r = archive_read_open_filename(a, multi_volume_pattern, 10240); if (r != ARCHIVE_OK) exit(1);
Is always -30 with .7z.001 files.

Help?

EDIT: Also running with the stock example at line

if (r < ARCHIVE_OK) fprintf(stderr, "%s\n", archive_error_string(a));
a red (null) is printed to the console.