summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkn00tcn <[email protected]>2017-03-07 22:10:34 -0500
committerZenWalker <[email protected]>2017-03-12 02:30:55 +0100
commite1646ec8dc32fe55fc610c7a17cf6c128a0827cc (patch)
treef12a08ab149f30dfdd18314b3a930b006f67ef29
parentcea0a8151f01fc367a1e8a8d3851dd5faaebc8a1 (diff)
downloadengrampa-e1646ec8dc32fe55fc610c7a17cf6c128a0827cc.tar.bz2
engrampa-e1646ec8dc32fe55fc610c7a17cf6c128a0827cc.tar.xz
Fix: rar file listing now shows correct date with recent binary
rar before version 5.30 used DD-MM-YY, but versions since then use YYYY-MM-DD, most people using rar would and should be using recent versions this fix reorders the string split so year is first and day is last in order to show the correct date when using rar version 5.30 onward the newer date format matches the one used by tar, so based on tar's code, this fix replaces support for year strings to four characters instead of two updated example listing output for rar versions is included and moved right before the time function instead of right after
-rw-r--r--src/fr-command-rar.c91
1 files changed, 56 insertions, 35 deletions
diff --git a/src/fr-command-rar.c b/src/fr-command-rar.c
index de19647..cae750b 100644
--- a/src/fr-command-rar.c
+++ b/src/fr-command-rar.c
@@ -55,6 +55,60 @@ have_rar (void)
/* -- 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 +123,11 @@ mktime_from_string (const char *date_s,
fields = g_strsplit (date_s, "-", 3);
if (fields[0] != NULL) {
- tm.tm_mday = atoi (fields[0]);
+ tm.tm_year = atoi (fields[0]) - 1900;
if (fields[1] != NULL) {
tm.tm_mon = atoi (fields[1]) - 1;
if (fields[2] != NULL)
- tm.tm_year = 100 + atoi (fields[2]);
+ tm.tm_mday = atoi (fields[2]);
}
}
g_strfreev (fields);
@@ -91,39 +145,6 @@ mktime_from_string (const char *date_s,
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)
{