ark: Fix unzip v6 date parsing

unzip v6 changed the date format from MM-DD-YY to YYYY-MM-DD.

Fixes: https://bugs.trinitydesktop.org/show_bug.cgi?id=3207
Signed-off-by: mio <stigma@disroot.org>
(cherry picked from commit 3a179b33ef)
r14.1.x
mio 11 months ago
parent 194a97c77a
commit 80ca7b28a3

@ -34,6 +34,7 @@
#include <tdelocale.h>
#include <tdemessagebox.h>
#include <kprocess.h>
#include <kprocio.h>
#include <kpassdlg.h>
// ark includes
@ -50,18 +51,66 @@ ZipArch::ZipArch( ArkWidget *_gui, const TQString & _fileName )
verifyCompressUtilityIsAvailable( m_archiver_program );
verifyUncompressUtilityIsAvailable( m_unarchiver_program );
// Compatibility with unzip v5 and v6.
// - unzip 5 prints dates as MM-DD-YY.
// - unzip 6 prints dates as YYYY-MM-DD.
// Presume version 6 as it was released in 2009.
bool unzipV5 = false;
if (m_bUnarchUtilityIsAvailable)
{
KProcIO proc;
proc << m_unarchiver_program;
proc << "-v";
if (proc.start(KProcIO::Block))
{
proc.wait();
if (proc.normalExit() && proc.exitStatus() == 0)
{
TQString line;
proc.readln(line);
auto parts = TQStringList::split(' ', line);
unzipV5 = (parts.size() >= 2) && (parts[1][0] == '5');
}
}
}
m_headerString = "----";
m_repairYear = 9; m_fixMonth = 7; m_fixDay = 8; m_fixTime = 10;
m_fixTime = 10;
m_dateCol = 5;
m_numCols = 7;
if (unzipV5)
{
kdDebug(1601) << "ZipArch: unzip v5 detected." << endl;
m_repairYear = 9;
m_fixMonth = 7;
m_fixDay = 8;
}
else
{
m_fixYear = 7;
m_fixMonth = 8;
m_fixDay = 9;
}
m_archCols.append( new ArchColumns( 1, TQRegExp( "[0-9]+" ) ) );
m_archCols.append( new ArchColumns( 2, TQRegExp( "[^\\s]+" ) ) );
m_archCols.append( new ArchColumns( 3, TQRegExp( "[0-9]+" ) ) );
m_archCols.append( new ArchColumns( 4, TQRegExp( "[0-9.]+%" ) ) );
m_archCols.append( new ArchColumns( 7, TQRegExp( "[01][0-9]" ), 2 ) );
m_archCols.append( new ArchColumns( 8, TQRegExp( "[0-3][0-9]" ), 2 ) );
m_archCols.append( new ArchColumns( 9, TQRegExp( "[0-9][0-9]" ), 2 ) );
if (unzipV5)
{
m_archCols.append( new ArchColumns( 7, TQRegExp( "[01][0-9]" ), 2 ) );
m_archCols.append( new ArchColumns( 8, TQRegExp( "[0-3][0-9]" ), 2 ) );
m_archCols.append( new ArchColumns( 9, TQRegExp( "[0-9][0-9]" ), 2 ) );
}
else
{
m_archCols.append( new ArchColumns( 7, TQRegExp( "[0-9]{4}" ), 4 ) );
m_archCols.append( new ArchColumns( 8, TQRegExp( "[01][0-9]" ), 2 ) );
m_archCols.append( new ArchColumns( 9, TQRegExp( "[0-3][0-9]" ), 2 ) );
}
m_archCols.append( new ArchColumns( 10, TQRegExp( "[0-9:]+" ), 6 ) );
m_archCols.append( new ArchColumns( 6, TQRegExp( "[a-fA-F0-9]+ {2}" ) ) );
m_archCols.append( new ArchColumns( 0, TQRegExp( "[^\\n]+" ), 4096 ) );

Loading…
Cancel
Save