summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorzhuyaliang <[email protected]>2023-03-20 23:06:44 +0800
committerLuke from DC <[email protected]>2023-04-23 06:27:26 +0000
commit6f49d2c72ea1ade71df33a301d5192c2a127e790 (patch)
tree4e37fe5650e092daf66aedf8346a627ead29c826 /src
parent872b71b88462358ab8bfe0fb83d4ce00abccb747 (diff)
downloadengrampa-6f49d2c72ea1ade71df33a301d5192c2a127e790.tar.bz2
engrampa-6f49d2c72ea1ade71df33a301d5192c2a127e790.tar.xz
command-7z: Add new 7-zip(7zz and 7zzs) project support
Diffstat (limited to 'src')
-rw-r--r--src/fr-command-7z.c35
-rw-r--r--src/fr-command-tar.c9
2 files changed, 30 insertions, 14 deletions
diff --git a/src/fr-command-7z.c b/src/fr-command-7z.c
index 4c5b03a..d1617ae 100644
--- a/src/fr-command-7z.c
+++ b/src/fr-command-7z.c
@@ -204,7 +204,15 @@ list__process_line (char *line,
static void
fr_command_7z_begin_command (FrCommand *comm)
{
- if (is_program_in_path ("7z"))
+ // Modern 7-Zip by the original author.
+ // Statically linked from a binary distribution, almost guaranteed to work.
+ if (is_program_in_path ("7zzs"))
+ fr_process_begin_command (comm->process, "7zzs");
+ // Dynamically linked from either binary or source distribution.
+ else if (is_program_in_path ("7zz"))
+ fr_process_begin_command (comm->process, "7zz");
+ // Legacy p7zip project.
+ else if (is_program_in_path ("7z"))
fr_process_begin_command (comm->process, "7z");
else if (is_program_in_path ("7za"))
fr_process_begin_command (comm->process, "7za");
@@ -333,8 +341,10 @@ fr_command_7z_add (FrCommand *comm,
if (spd_support) fr_process_add_arg (comm->process, "-spd");
fr_process_add_arg (comm->process, "-bd");
+ fr_process_add_arg (comm->process, "-bb1");
fr_process_add_arg (comm->process, "-y");
- fr_process_add_arg (comm->process, "-l");
+ if (recursive)
+ fr_process_add_arg (comm->process, "-l");
add_password_arg (comm, comm->password, FALSE);
if ((comm->password != NULL)
&& (*comm->password != 0)
@@ -482,6 +492,7 @@ fr_command_7z_extract (FrCommand *comm,
if (spd_support) fr_process_add_arg (comm->process, "-spd");
fr_process_add_arg (comm->process, "-bd");
+ fr_process_add_arg (comm->process, "-bb1");
fr_process_add_arg (comm->process, "-y");
add_password_arg (comm, comm->password, FALSE);
@@ -617,24 +628,28 @@ fr_command_7z_get_capabilities (FrCommand *comm,
FrCommandCaps capabilities;
capabilities = FR_COMMAND_CAN_ARCHIVE_MANY_FILES;
- if (! is_program_available ("7za", check_command) && ! is_program_available ("7zr", check_command) && ! is_program_available ("7z", check_command))
+ gboolean available_7zip = is_program_available ("7zz", check_command) || is_program_available ("7zzs", check_command);
+ if (! available_7zip\
+ && ! is_program_available ("7za", check_command) \
+ && ! is_program_available ("7zr", check_command) \
+ && ! is_program_available ("7z", check_command))
return capabilities;
if (is_mime_type (mime_type, "application/x-7z-compressed")) {
capabilities |= FR_COMMAND_CAN_READ_WRITE | FR_COMMAND_CAN_CREATE_VOLUMES;
- if (is_program_available ("7z", check_command))
+ if (is_program_available ("7z", check_command) || available_7zip)
capabilities |= FR_COMMAND_CAN_ENCRYPT | FR_COMMAND_CAN_ENCRYPT_HEADER;
}
else if (is_mime_type (mime_type, "application/x-7z-compressed-tar")) {
capabilities |= FR_COMMAND_CAN_READ_WRITE;
- if (is_program_available ("7z", check_command))
+ if (is_program_available ("7z", check_command) || available_7zip)
capabilities |= FR_COMMAND_CAN_ENCRYPT | FR_COMMAND_CAN_ENCRYPT_HEADER;
}
- else if (is_program_available ("7z", check_command)) {
+ else if (is_program_available ("7z", check_command) || available_7zip) {
if (is_mime_type (mime_type, "application/x-rar")
|| is_mime_type (mime_type, "application/x-cbr"))
{
- if (! check_command || g_file_test ("/usr/lib/p7zip/Codecs/Rar29.so", G_FILE_TEST_EXISTS) || g_file_test ("/usr/lib/p7zip/Codecs/Rar.so", G_FILE_TEST_EXISTS)
+ if (! check_command || available_7zip || g_file_test ("/usr/lib/p7zip/Codecs/Rar29.so", G_FILE_TEST_EXISTS) || g_file_test ("/usr/lib/p7zip/Codecs/Rar.so", G_FILE_TEST_EXISTS)
|| g_file_test ("/usr/libexec/p7zip/Codecs/Rar29.so", G_FILE_TEST_EXISTS) || g_file_test ("/usr/libexec/p7zip/Codecs/Rar.so", G_FILE_TEST_EXISTS))
capabilities |= FR_COMMAND_CAN_READ;
}
@@ -672,11 +687,11 @@ fr_command_7z_get_packages (FrCommand *comm,
const char *mime_type)
{
if (is_mime_type (mime_type, "application/x-rar"))
- return PACKAGES ("p7zip,p7zip-rar");
+ return PACKAGES ("7zip,7zip-rar");
else if (is_mime_type (mime_type, "application/zip") || is_mime_type (mime_type, "application/vnd.ms-cab-compressed"))
- return PACKAGES ("p7zip,p7zip-full");
+ return PACKAGES ("7zip,7zip-full");
else
- return PACKAGES ("p7zip");
+ return PACKAGES ("7zip");
}
static void
diff --git a/src/fr-command-tar.c b/src/fr-command-tar.c
index e73b214..79c0ad0 100644
--- a/src/fr-command-tar.c
+++ b/src/fr-command-tar.c
@@ -664,7 +664,8 @@ fr_command_tar_recompress (FrCommand *comm)
fr_process_add_arg (comm->process, "a");
fr_process_add_arg (comm->process, "-bd");
fr_process_add_arg (comm->process, "-y");
- fr_process_add_arg (comm->process, "-l");
+ if (g_strcmp0 (comm_tar->compress_command, "7zzs") != 0 && g_strcmp0 (comm_tar->compress_command, "7zz") != 0)
+ fr_process_add_arg (comm->process, "-l");
new_name = g_strconcat (c_tar->uncomp_filename, ".7z", NULL);
fr_process_add_arg_concat (comm->process, new_name, NULL);
@@ -1061,7 +1062,7 @@ fr_command_tar_get_capabilities (FrCommand *comm,
capabilities |= FR_COMMAND_CAN_READ_WRITE;
}
else if (is_mime_type (mime_type, "application/x-7z-compressed-tar")) {
- const char *try_command[3] = { "7za", "7zr", "7z" };
+ const char *try_command[5] = { "7zzs", "7zz", "7za", "7zr", "7z" };
size_t i;
for (i = 0; i < G_N_ELEMENTS (try_command); i++) {
@@ -1088,7 +1089,7 @@ fr_command_tar_set_mime_type (FrCommand *comm,
FR_COMMAND_CLASS (parent_class)->set_mime_type (comm, mime_type);
if (is_mime_type (mime_type, "application/x-7z-compressed-tar")) {
- const char *try_command[3] = { "7za", "7zr", "7z" };
+ const char *try_command[5] = { "7zzs", "7zz", "7za", "7zr", "7z" };
size_t i;
for (i = 0; i < G_N_ELEMENTS (try_command); i++) {
@@ -1125,7 +1126,7 @@ fr_command_tar_get_packages (FrCommand *comm,
else if (is_mime_type (mime_type, "application/x-lzop-compressed-tar"))
return PACKAGES ("tar,lzop");
else if (is_mime_type (mime_type, "application/x-7z-compressed-tar"))
- return PACKAGES ("tar,p7zip");
+ return PACKAGES ("tar,7zip");
else if (is_mime_type (mime_type, "application/x-zstd-compressed-tar"))
return PACKAGES ("tar,zstd");