summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorrbuj <[email protected]>2022-07-25 11:21:44 +0200
committerrbuj <[email protected]>2022-07-27 18:20:45 +0200
commitaf5c712303300271e8da41d7cdf5b8539ed3a447 (patch)
tree824d0c5aedf3cdfd3717d8dc13afedee471bf814 /src
parent84b1bd2cdb55d1a293c7f19ee4585c1eeeac2879 (diff)
downloadengrampa-af5c712303300271e8da41d7cdf5b8539ed3a447.tar.bz2
engrampa-af5c712303300271e8da41d7cdf5b8539ed3a447.tar.xz
fr-command-rar: add has_date_newstylehas_date_newstyle
Diffstat (limited to 'src')
-rw-r--r--src/fr-command-rar.c55
1 files changed, 25 insertions, 30 deletions
diff --git a/src/fr-command-rar.c b/src/fr-command-rar.c
index 7794510..a2de40b 100644
--- a/src/fr-command-rar.c
+++ b/src/fr-command-rar.c
@@ -208,6 +208,27 @@ attr_field_is_dir (const char *attr_field,
return FALSE;
}
+static gboolean
+has_date_newstyle (const char *line,
+ gboolean is_rar,
+ gboolean *rar5)
+{
+ int version_major;
+ int version_minor;
+
+ sscanf (line, is_rar ? "RAR %d.%d" : "UNRAR %d.%d",
+ &version_major, &version_minor);
+ *rar5 = (version_major >= 5);
+
+ if (version_major > 5)
+ return TRUE;
+
+ if ((version_major == 5) && (version_minor >= 30))
+ return TRUE;
+
+ return FALSE;
+}
+
static void
process_line (char *line,
gpointer data)
@@ -219,36 +240,10 @@ process_line (char *line,
g_return_if_fail (line != NULL);
if (! rar_comm->list_started) {
- if (strncmp (line, "RAR ", 4) == 0) {
- 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;
- }
-
- }
+ if (strncmp (line, "RAR ", 4) == 0)
+ date_newstyle = has_date_newstyle (line, TRUE, &rar_comm->rar5);
+ else if (strncmp (line, "UNRAR ", 6) == 0)
+ date_newstyle = has_date_newstyle (line, FALSE, &rar_comm->rar5);
else if (strncmp (line, "--------", 8) == 0) {
rar_comm->list_started = TRUE;
if (! rar_comm->rar5)