diff '--color=auto' -aur a/src/file-data.c b/src/file-data.c --- a/src/file-data.c 2016-04-07 04:37:58.000000000 -0700 +++ b/src/file-data.c 2017-03-13 05:45:12.000000000 -0700 @@ -37,7 +37,7 @@ fdata->content_type = NULL; fdata->free_original_path = FALSE; fdata->dir_size = 0; - + return fdata; } @@ -54,6 +54,7 @@ g_free (fdata->path); g_free (fdata->link); g_free (fdata->list_name); + g_free (fdata->sort_key); g_free (fdata); } @@ -67,7 +68,7 @@ fdata->original_path = g_strdup (src->original_path); fdata->free_original_path = TRUE; - + fdata->full_path = g_strdup (src->full_path); fdata->link = g_strdup (src->link); fdata->size = src->size; @@ -81,6 +82,7 @@ fdata->list_dir = src->list_dir; fdata->list_name = g_strdup (src->list_name); + fdata->sort_key = g_strdup (src->sort_key); return fdata; } @@ -90,10 +92,10 @@ file_data_get_type (void) { static GType type = 0; - + if (type == 0) type = g_boxed_type_register_static ("FRFileData", (GBoxedCopyFunc) file_data_copy, (GBoxedFreeFunc) file_data_free); - + return type; } @@ -101,10 +103,9 @@ void file_data_update_content_type (FileData *fdata) { - - if (fdata->dir) + if (fdata->dir) fdata->content_type = MIME_TYPE_DIRECTORY; - else + else fdata->content_type = get_static_string (g_content_type_guess (fdata->full_path, NULL, 0, NULL)); } @@ -116,13 +117,28 @@ } +void +file_data_set_list_name (FileData *fdata, + const char *value) +{ + g_free (fdata->list_name); + fdata->list_name = g_strdup (value); + + g_free (fdata->sort_key); + if (fdata->list_name != NULL) + fdata->sort_key = g_utf8_collate_key_for_filename (fdata->list_name, -1); + else + fdata->sort_key = NULL; +} + + int file_data_compare_by_path (gconstpointer a, gconstpointer b) { FileData *data_a = *((FileData **) a); FileData *data_b = *((FileData **) b); - + return strcmp (data_a->full_path, data_b->full_path); } @@ -158,12 +174,12 @@ } if (cmp == 0) - return p; + return p; else if (cmp < 0) right = p; - else + else left = p + 1; } - + return -1; } diff '--color=auto' -aur a/src/file-data.h b/src/file-data.h --- a/src/file-data.h 2016-04-07 04:37:58.000000000 -0700 +++ b/src/file-data.h 2017-03-13 05:45:12.000000000 -0700 @@ -40,13 +40,14 @@ gboolean dir; /* Whether this is a directory listed in the archive */ goffset dir_size; const char *content_type; - + /* Additional data. */ gboolean list_dir; /* Whether this entry is used to show * a directory. */ char *list_name; /* The string visualized in the list * view. */ + char *sort_key; /* Private data */ @@ -57,14 +58,15 @@ GType file_data_get_type (void); FileData * file_data_new (void); -FileData * file_data_copy (FileData *src); -void file_data_free (FileData *fdata); -void file_data_update_content_type (FileData *fdata); -gboolean file_data_is_dir (FileData *fdata); - -int file_data_compare_by_path (gconstpointer a, - gconstpointer b); -int find_path_in_file_data_array (GPtrArray *array, - const char *path); +FileData * file_data_copy (FileData *src); +void file_data_free (FileData *fdata); +void file_data_update_content_type (FileData *fdata); +gboolean file_data_is_dir (FileData *fdata); +void file_data_set_list_name (FileData *fdata, + const char *value); +int file_data_compare_by_path (gconstpointer a, + gconstpointer b); +int find_path_in_file_data_array (GPtrArray *array, + const char *path); #endif /* FILE_DATA_H */ diff '--color=auto' -aur a/src/fr-command-7z.c b/src/fr-command-7z.c --- a/src/fr-command-7z.c 2016-04-07 04:37:58.000000000 -0700 +++ b/src/fr-command-7z.c 2017-03-13 05:45:12.000000000 -0700 @@ -39,7 +39,8 @@ static void fr_command_7z_class_init (FrCommand7zClass *class); static void fr_command_7z_init (FrCommand *afile); static void fr_command_7z_finalize (GObject *object); -static gboolean spd_support; +static gboolean spd_support = FALSE; +static gboolean unexpected_end_of_archive = FALSE; /* Parent Class */ @@ -125,6 +126,9 @@ comm->multi_volume = (strcmp (fields[1], "+") == 0); g_strfreev (fields); } + else if (strncmp (line, "Unexpected end of archive", 25) == 0) { + unexpected_end_of_archive = TRUE; + } return; } @@ -280,7 +284,7 @@ { FrCommand *comm = FR_COMMAND (data); - if ((comm->volume_size > 0) && (strncmp (line, "Creating archive ", 17) == 0)) { + if ((comm->volume_size > 0) && (strncmp (line, "Creating archive", 16) == 0)) { char *volume_filename; GFile *volume_file; @@ -371,11 +375,20 @@ if (from_file != NULL) fr_process_add_arg_concat (comm->process, "-i@", from_file, NULL); + if (from_file == NULL) + for (scan = file_list; scan; scan = scan->next) + /* Files prefixed with '@' need to be handled specially */ + if (g_str_has_prefix (scan->data, "@")) + fr_process_add_arg_concat (comm->process, "-i!", scan->data, NULL); + fr_process_add_arg (comm->process, "--"); fr_process_add_arg (comm->process, comm->filename); + if (from_file == NULL) for (scan = file_list; scan; scan = scan->next) - fr_process_add_arg (comm->process, scan->data); + /* Skip files prefixed with '@', already added */ + if (!g_str_has_prefix (scan->data, "@")) + fr_process_add_arg (comm->process, scan->data); fr_process_end_command (comm->process); } @@ -399,11 +412,20 @@ if (from_file != NULL) fr_process_add_arg_concat (comm->process, "-i@", from_file, NULL); + if (from_file == NULL) + for (scan = file_list; scan; scan = scan->next) + /* Files prefixed with '@' need to be handled specially */ + if (g_str_has_prefix (scan->data, "@")) + fr_process_add_arg_concat (comm->process, "-i!", scan->data, NULL); + fr_process_add_arg (comm->process, "--"); fr_process_add_arg (comm->process, comm->filename); + if (from_file == NULL) for (scan = file_list; scan; scan = scan->next) - fr_process_add_arg (comm->process, scan->data); + /* Skip files prefixed with '@', already added */ + if (!g_str_has_prefix (scan->data, "@")) + fr_process_add_arg (comm->process, scan->data); fr_process_end_command (comm->process); } @@ -453,11 +475,22 @@ if (from_file != NULL) fr_process_add_arg_concat (comm->process, "-i@", from_file, NULL); + if (from_file == NULL) + for (scan = file_list; scan; scan = scan->next) + /* Files prefixed with '@' need to be handled specially */ + if (g_str_has_prefix (scan->data, "@")) + fr_process_add_arg_concat (comm->process, "-i!", scan->data, NULL); + fr_process_add_arg (comm->process, "--"); fr_process_add_arg (comm->process, comm->filename); + if (from_file == NULL) for (scan = file_list; scan; scan = scan->next) - fr_process_add_arg (comm->process, scan->data); + /* Skip files prefixed with '@', already added */ + if (!g_str_has_prefix (scan->data, "@")) + fr_process_add_arg (comm->process, scan->data); + + if (unexpected_end_of_archive) fr_process_set_ignore_error (comm->process, TRUE); fr_process_end_command (comm->process); } @@ -507,7 +540,7 @@ return; } - if (error->status <= 1) { + if ((error->status <= 1) || (unexpected_end_of_archive)) { error->type = FR_PROC_ERROR_NONE; } else { @@ -572,7 +605,8 @@ 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)) + 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) + || 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; } else diff '--color=auto' -aur a/src/fr-command-lha.c b/src/fr-command-lha.c --- a/src/fr-command-lha.c 2016-04-07 04:37:58.000000000 -0700 +++ b/src/fr-command-lha.c 2017-03-13 05:45:12.000000000 -0700 @@ -120,6 +120,11 @@ fields[i++] = g_strdup (""); line += strlen ("[unknown]"); } + else if (strncmp (line, "[Amiga]", 7) == 0) { + fields[i++] = g_strdup (""); + fields[i++] = g_strdup (""); + line += strlen ("[Amiga]"); + } scan = eat_spaces (line); for (; i < n_fields; i++) { @@ -150,6 +155,9 @@ if (strncmp (line, "[unknown]", 9) == 0) n--; + if (strncmp (line, "[Amiga]", 7) == 0) + n--; + field = eat_spaces (line); for (i = 0; i < n; i++) { field = strchr (field, ' '); diff '--color=auto' -aur a/src/fr-command-rar.c b/src/fr-command-rar.c --- a/src/fr-command-rar.c 2016-04-07 04:37:58.000000000 -0700 +++ b/src/fr-command-rar.c 2017-03-13 05:45:12.000000000 -0700 @@ -46,6 +46,10 @@ static FrCommandClass *parent_class = NULL; +/* rar 5.30 and later uses YYYY-MM-DD instead DD-MM-YY in the listing output */ + +static gboolean date_newstyle = FALSE; + static gboolean have_rar (void) { @@ -55,6 +59,60 @@ /* -- list -- */ +/* + +// SAMPLE RAR VERSION 5.30 AND NEWER LISTING OUTPUT: + +RAR 5.30 Copyright (c) 1993-2015 Alexander Roshal 18 Nov 2015 +Trial version Type RAR -? for help + +Archive: /test.rar +Details: RAR 4 + + Attributes Size Packed Ratio Date Time Checksum Name +----------- --------- -------- ----- ---------- ----- -------- ---- + -rw-rw-r-- 3165 1310 41% 2017-03-07 21:34 888D50B3 loremipsum.txt + -rw-rw-r-- 0 8 0% 2017-03-07 21:36 00000000 file2.empty +----------- --------- -------- ----- ---------- ----- -------- ---- + 3165 1318 41% 2 + + + +// SAMPLE RAR VERSION 5.00 TO 5.21 LISTING OUTPUT: + +RAR 5.21 Copyright (c) 1993-2015 Alexander Roshal 15 Feb 2015 +Trial version Type RAR -? for help + +Archive: /test.rar +Details: RAR 4 + + Attributes Size Packed Ratio Date Time Checksum Name +----------- --------- -------- ----- -------- ----- -------- ---- + -rw-rw-r-- 3165 1310 41% 07-03-17 21:34 888D50B3 loremipsum.txt + -rw-rw-r-- 0 8 0% 07-03-17 21:36 00000000 file2.empty +----------- --------- -------- ----- -------- ----- -------- ---- + 3165 1318 41% 2 + + + +// SAMPLE RAR VERSION 4.20 AND OLDER LISTING OUTPUT: + +RAR 4.20 Copyright (c) 1993-2012 Alexander Roshal 9 Jun 2012 +Trial version Type RAR -? for help + +Archive /test.rar + +Pathname/Comment + Size Packed Ratio Date Time Attr CRC Meth Ver +------------------------------------------------------------------------------- + loremipsum.txt + 3165 1310 41% 07-03-17 21:34 -rw-rw-r-- 888D50B3 m3b 2.9 + file2.empty + 0 8 0% 07-03-17 21:36 -rw-rw-r-- 00000000 m3b 2.9 +------------------------------------------------------------------------------- + 2 3165 1318 41% + +*/ static time_t mktime_from_string (const char *date_s, @@ -69,11 +127,18 @@ fields = g_strsplit (date_s, "-", 3); if (fields[0] != NULL) { - tm.tm_mday = atoi (fields[0]); + if (date_newstyle) + tm.tm_year = atoi (fields[0]) - 1900; + else + tm.tm_mday = atoi (fields[0]); if (fields[1] != NULL) { tm.tm_mon = atoi (fields[1]) - 1; - if (fields[2] != NULL) - tm.tm_year = 100 + atoi (fields[2]); + if (fields[2] != NULL) { + if (date_newstyle) + tm.tm_mday = atoi (fields[2]); + else + tm.tm_year = 100 + atoi (fields[2]); + } } } g_strfreev (fields); @@ -91,39 +156,6 @@ return mktime (&tm); } -/* Sample rar-5 listing output: - -RAR 5.00 beta 8 Copyright (c) 1993-2013 Alexander Roshal 22 Aug 2013 -Trial version Type RAR -? for help - -Archive: test.rar -Details: RAR 4 - - Attributes Size Packed Ratio Date Time Checksum Name ------------ --------- -------- ----- -------- ----- -------- ---- - -rw-r--r-- 453 304 67% 05-09-13 09:55 56DA5EF3 loremipsum.txt ------------ --------- -------- ----- -------- ----- -------- ---- - 453 304 67% 1 - - * - * Sample rar-4 listing output: - * - -RAR 4.20 Copyright (c) 1993-2012 Alexander Roshal 9 Jun 2012 -Trial version Type RAR -? for help - -Archive test.rar - -Pathname/Comment - Size Packed Ratio Date Time Attr CRC Meth Ver -------------------------------------------------------------------------------- - loremipsum.txt - 453 304 67% 05-09-13 09:55 -rw-r--r-- 56DA5EF3 m3b 2.9 -------------------------------------------------------------------------------- - 1 453 304 67% - - */ - static gboolean attribute_field_with_space (char *line) { @@ -197,11 +229,31 @@ int version; sscanf (line, "RAR %d.", &version); rar_comm->rar5 = (version >= 5); + + if (version > 5) + date_newstyle = TRUE; + else if (version == 5) + { + sscanf (line, "RAR 5.%d ", &version); + if (version >= 30) + date_newstyle = TRUE; + } + } else if (strncmp (line, "UNRAR ", 6) == 0) { int version; sscanf (line, "UNRAR %d.", &version); rar_comm->rar5 = (version >= 5); + + if (version > 5) + date_newstyle = TRUE; + else if (version == 5) + { + sscanf (line, "UNRAR 5.%d ", &version); + if (version >= 30) + date_newstyle = TRUE; + } + } else if (strncmp (line, "--------", 8) == 0) { rar_comm->list_started = TRUE; diff '--color=auto' -aur a/src/fr-command-tar.c b/src/fr-command-tar.c --- a/src/fr-command-tar.c 2016-05-21 07:44:10.000000000 -0700 +++ b/src/fr-command-tar.c 2017-03-13 05:45:12.000000000 -0700 @@ -198,7 +198,10 @@ fr_process_add_arg (comm->process, "-z"); else if (is_mime_type (comm->mime_type, "application/x-bzip-compressed-tar")) - fr_process_add_arg (comm->process, "--use-compress-program=bzip2"); + if (is_program_in_path ("lbzip2")) + fr_process_add_arg (comm->process, "--use-compress-program=lbzip2"); + else + fr_process_add_arg (comm->process, "--use-compress-program=bzip2"); else if (is_mime_type (comm->mime_type, "application/x-tarz")) { if (is_program_in_path ("gzip")) @@ -216,7 +219,10 @@ fr_process_add_arg (comm->process, "--use-compress-program=lzma"); else if (is_mime_type (comm->mime_type, "application/x-xz-compressed-tar")) - fr_process_add_arg (comm->process, "--use-compress-program=xz"); + if (is_program_in_path ("pixz")) + fr_process_add_arg (comm->process, "--use-compress-program=pixz"); + else + fr_process_add_arg (comm->process, "--use-compress-program=xz"); else if (is_mime_type (comm->mime_type, "application/x-lzop-compressed-tar")) fr_process_add_arg (comm->process, "--use-compress-program=lzop"); diff '--color=auto' -aur a/src/fr-command-zip.c b/src/fr-command-zip.c --- a/src/fr-command-zip.c 2016-04-07 04:37:58.000000000 -0700 +++ b/src/fr-command-zip.c 2017-03-13 05:45:12.000000000 -0700 @@ -382,7 +382,9 @@ const char *zip_mime_type[] = { "application/x-cbz", + "application/x-ear", "application/x-ms-dos-executable", + "application/x-war", "application/zip", NULL }; diff '--color=auto' -aur a/src/fr-init.c b/src/fr-init.c --- a/src/fr-init.c 2016-04-07 04:37:58.000000000 -0700 +++ b/src/fr-init.c 2017-03-17 16:08:13.736744366 -0700 @@ -342,6 +342,7 @@ register_command (FR_TYPE_COMMAND_TAR); register_command (FR_TYPE_COMMAND_CFILE); + register_command (FR_TYPE_COMMAND_RAR); register_command (FR_TYPE_COMMAND_7Z); register_command (FR_TYPE_COMMAND_DPKG); @@ -353,7 +354,6 @@ register_command (FR_TYPE_COMMAND_ISO); register_command (FR_TYPE_COMMAND_JAR); register_command (FR_TYPE_COMMAND_LHA); - register_command (FR_TYPE_COMMAND_RAR); register_command (FR_TYPE_COMMAND_RPM); register_command (FR_TYPE_COMMAND_UNSTUFF); register_command (FR_TYPE_COMMAND_ZIP); diff '--color=auto' -aur a/src/fr-process.c b/src/fr-process.c --- a/src/fr-process.c 2016-04-07 04:37:58.000000000 -0700 +++ b/src/fr-process.c 2017-03-13 05:45:12.000000000 -0700 @@ -675,14 +675,47 @@ char **argv; int out_fd, err_fd; int i = 0; + char *commandline = ""; + gboolean fixname = FALSE; debug (DEBUG_INFO, "%d/%d) ", process->priv->current_command, process->priv->n_comm); info = g_ptr_array_index (process->priv->comm, process->priv->current_command); argv = g_new (char *, g_list_length (info->args) + 1); - for (scan = info->args; scan; scan = scan->next) + + for (scan = info->args; scan; scan = scan->next) { argv[i++] = scan->data; + + if (g_str_has_prefix(commandline, "mv")) { + + if ((i==3) && (!g_file_test(argv[2], G_FILE_TEST_EXISTS)) && (!fixname)) { + char rarfile[strlen(argv[2])+7]; + + strcpy(rarfile, argv[2]); + rarfile[strlen(rarfile)-3]=0; + strcat(rarfile, "part1.rar"); + + if (g_str_has_suffix(argv[2], ".7z")) { + commandline = g_strconcat(commandline, " ", g_shell_quote(argv[2]), ".*", NULL); + fixname = TRUE; + } + else if (g_str_has_suffix(argv[2], ".rar")) { + rarfile[strlen(rarfile)-5]=0; + commandline = g_strconcat(commandline, " ", g_shell_quote(rarfile), "*.rar", NULL); + fixname = TRUE; + } + } + else if ((i==4) && (fixname)) + commandline = g_strconcat(commandline, " \"$(dirname ", g_shell_quote(argv[3]), ")\"", NULL); + else + commandline = g_strconcat(commandline, " ", argv[(i-1)], NULL); + } + else if (g_str_has_prefix(argv[0], "mv")) { + commandline = g_strconcat(commandline, "mv", NULL); + } + } + argv[i] = NULL; #ifdef DEBUG @@ -702,6 +735,11 @@ } #endif + if ((fixname) && (system(commandline) != 0)) { + g_warning ("The files could not be move: %s\n", commandline); + return; + } + if (info->begin_func != NULL) (*info->begin_func) (info->begin_data);