ark: restore unzip-5 support

See-also: https://mirror.git.trinitydesktop.org/gitea/TDE/tdeutils/pulls/117#issuecomment-82676
Signed-off-by: Alexander Golubev <fatzer2@gmail.com>
master
Alexander Golubev 2 weeks ago
parent 14d84907a0
commit 1ddc8e16d8

@ -40,6 +40,7 @@
// ark includes
#include "zip.h"
#include "arkutils.h"
#include "arkwidget.h"
#include "settings.h"
#include "filelistview.h"
@ -324,22 +325,23 @@ bool ZipArch::processLine( const TQCString &line )
return false;
}
// unzip-6 can be configured at build time to return date in either of three
// formats:
// unzip can be configured at build time to return date in either of three
// formats (for version 6):
// - MM-DD-YYYY (the default on *nix systems)
// - DD-MM-YYYY (not used by default)
// - YYYY-MM-DD (used in several linux distribution e.g. debian)
// Unfortunately there is no easy way to query unzip which format it does
// use, so we will have to guestimate here. Also since the DMY is not widely
// used and in general case indistinguishable from MDY we will ignore it and
// concentrate on distinguishing between MDY and YMD. Luckily unzip-6 unlike
// unzip-5 uses 4 digits for years, so it will be relatively painless.
// concentrate on distinguishing between MDY and YMD. Luckily unzip-6 uses
// 4 digits for years, so it will be relatively painless. On the other hand
// unzip-5 uses 2-digits for a year, so in that case always assume MDY.
TQString date = lineRx.cap(5);
TQString time = lineRx.cap(6);
TQRegExp mdyDateRx{"^([01][0-9])-([0-3][0-9])-([0-9]{4,})$"};
TQRegExp mdyDateRx{"^([01][0-9])-([0-3][0-9])-([0-9]{2,})$"};
if(mdyDateRx.search(date) != -1) {
date = mdyDateRx.cap(3) + "-" + mdyDateRx.cap(1) + "-" + mdyDateRx.cap(2);
date = ArkUtils::fixYear(mdyDateRx.cap(3)) + "-" + mdyDateRx.cap(1) + "-" + mdyDateRx.cap(2);
}
TQString timestamp = date + " " + time;

Loading…
Cancel
Save