summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZenWalker <[email protected]>2017-03-13 02:02:22 +0100
committerZenWalker <[email protected]>2017-03-13 02:02:22 +0100
commit960c581b01648a080b5d2d8ddc0ee76f556fd7fb (patch)
treeff290a6b8806c222714e0833609599c46591cab3
parente1646ec8dc32fe55fc610c7a17cf6c128a0827cc (diff)
downloadengrampa-960c581b01648a080b5d2d8ddc0ee76f556fd7fb.tar.bz2
engrampa-960c581b01648a080b5d2d8ddc0ee76f556fd7fb.tar.xz
check the rar/unrar version to work the new date style with all versions
rar 5.30 and later uses YYYY-MM-DD instead DD-MM-YY in the listing output
-rw-r--r--src/fr-command-rar.c37
1 files changed, 34 insertions, 3 deletions
diff --git a/src/fr-command-rar.c b/src/fr-command-rar.c
index cae750b..34a6730 100644
--- a/src/fr-command-rar.c
+++ b/src/fr-command-rar.c
@@ -46,6 +46,10 @@ static void fr_command_rar_finalize (GObject *object);
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)
{
@@ -123,11 +127,18 @@ mktime_from_string (const char *date_s,
fields = g_strsplit (date_s, "-", 3);
if (fields[0] != NULL) {
- tm.tm_year = atoi (fields[0]) - 1900;
+ 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_mday = 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);
@@ -218,11 +229,31 @@ process_line (char *line,
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;