summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichele Calgaro <michele.calgaro@yahoo.it>2016-04-22 22:20:18 +1000
committerMichele Calgaro <michele.calgaro@yahoo.it>2016-04-22 22:20:18 +1000
commit4e99fc39eb61da7ad6fedaa05df76101c6db571e (patch)
treed5eff19d213ed8f0b3d328dd1dfeb0219f4df0fd
parent08151b49b072892f7ccf9baaa3084f2cccbbde9e (diff)
downloadtdeutils-4e99fc39.tar.gz
tdeutils-4e99fc39.zip
Ark: added support for rar/unrar 5.x utilities. Both 4.x and 5.x are supported.
Special thanks to Fabio Rossi <rossi.f@inwind.it> for raising the issue and providing an initial patch. Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
-rw-r--r--ark/rar.cpp114
-rw-r--r--ark/rar.h1
2 files changed, 82 insertions, 33 deletions
diff --git a/ark/rar.cpp b/ark/rar.cpp
index 4d6a7ce..e47c78a 100644
--- a/ark/rar.cpp
+++ b/ark/rar.cpp
@@ -52,8 +52,10 @@
#include "arkutils.h"
#include "filelistview.h"
+#define VERSION_5 5
+
RarArch::RarArch( ArkWidget *_gui, const TQString & _fileName )
- : Arch( _gui, _fileName )
+ : Arch( _gui, _fileName ), m_isFirstLine(false), m_version(0)
{
// Check if rar is available
bool have_rar = !TDEGlobal::dirs()->findExe( "rar" ).isNull();
@@ -82,11 +84,7 @@ RarArch::RarArch( ArkWidget *_gui, const TQString & _fileName )
setReadOnly( true );
}
-
-
- m_headerString = "-------------------------------------------------------------------------------";
-
- m_isFirstLine = true;
+ m_headerString = "";
}
bool RarArch::processLine( const TQCString &line )
@@ -96,7 +94,33 @@ bool RarArch::processLine( const TQCString &line )
TQTextCodec *codec = TQTextCodec::codecForLocale();
unicode_line = codec->toUnicode( line );
- if ( m_isFirstLine )
+ // Look for rar/unrar version first
+ if (!m_version)
+ {
+ if (line.left(3) == "RAR")
+ {
+ bool ok_flag = false;
+ short version = line.mid(4, 1).toShort(&ok_flag);
+ if (ok_flag)
+ {
+ m_version = version;
+ if (m_version < VERSION_5)
+ {
+ m_headerString = "-------------------------------------------------------------------------------";
+ m_isFirstLine = true;
+ }
+ else
+ {
+ m_headerString = "----------- --------- -------- ----- ---------- ----- -------- ----";
+ }
+ setHeaders();
+ return true;
+ }
+ }
+ return false;
+ }
+
+ if (m_version < VERSION_5 && m_isFirstLine)
{
m_entryFilename = TQString::fromLocal8Bit( line );
m_entryFilename.remove( 0, 1 );
@@ -105,37 +129,59 @@ bool RarArch::processLine( const TQCString &line )
}
TQStringList list;
-
TQStringList l2 = TQStringList::split( ' ', line );
- if( l2[5].startsWith("d") )
+ if (m_version < VERSION_5)
{
- m_isFirstLine = true;
- return true;
- }
-
- list << m_entryFilename; // filename
- list << l2[ 0 ]; // size
- list << l2[ 1 ]; // packed
- list << l2[ 2 ]; // ratio
-
- TQStringList date = TQStringList::split( '-', l2[ 3 ] );
- list << ArkUtils::fixYear( date[ 2 ].latin1() ) + '-' + date[ 1 ] + '-' + date [ 0 ] + ' ' + l2[4]; // date
- list << l2[ 5 ]; // attributes
- list << l2[ 6 ]; // crc
- list << l2[ 7 ]; // method
- list << l2[ 8 ]; // Version
-
- m_gui->fileList()->addItem( list ); // send to GUI
-
- m_isFirstLine = true;
+ if( l2[5].startsWith("d") )
+ {
+ // Folder item
+ m_isFirstLine = true;
+ return true;
+ }
+
+ list << m_entryFilename; // filename
+ list << l2[ 0 ]; // size
+ list << l2[ 1 ]; // packed
+ list << l2[ 2 ]; // ratio
+
+ TQStringList date = TQStringList::split( '-', l2[ 3 ] );
+ list << ArkUtils::fixYear( date[ 2 ].latin1() ) + '-' + date[ 1 ] + '-' + date [ 0 ] + ' ' + l2[4]; // date
+ list << l2[ 5 ]; // attributes
+ list << l2[ 6 ]; // crc
+ list << l2[ 7 ]; // method
+ list << l2[ 8 ]; // Version
+
+ m_gui->fileList()->addItem( list ); // send to GUI
+
+ m_isFirstLine = true;
+ }
+ else
+ {
+ if( l2[0].startsWith("d") )
+ {
+ // Folder item
+ return true;
+ }
+
+ m_entryFilename = line.mid(line.find(l2[7]));
+ list << m_entryFilename; // filename
+ list << l2[ 1 ]; // size
+ list << l2[ 2 ]; // packed
+ list << l2[ 3 ]; // ratio
+
+ TQStringList date = TQStringList::split('-', l2[4]);
+ list << l2[ 4 ] + " " + l2[ 5 ]; // date and time
+ list << l2[ 0 ]; // attributes
+ list << l2[ 6 ]; // crc
+
+ m_gui->fileList()->addItem( list ); // send to GUI
+ }
return true;
}
void RarArch::open()
{
- setHeaders();
-
m_buffer = "";
m_header_removed = false;
m_finished = false;
@@ -174,9 +220,11 @@ void RarArch::setHeaders()
list.append( TIMESTAMP_COLUMN );
list.append( PERMISSION_COLUMN );
list.append( CRC_COLUMN );
- list.append( METHOD_COLUMN );
- list.append( VERSION_COLUMN );
-
+ if (m_version < VERSION_5)
+ {
+ list.append( METHOD_COLUMN );
+ list.append( VERSION_COLUMN );
+ }
emit headers( list );
}
diff --git a/ark/rar.h b/ark/rar.h
index 9bd0aea..fadb3e9 100644
--- a/ark/rar.h
+++ b/ark/rar.h
@@ -65,6 +65,7 @@ class RarArch : public Arch
* Therefore, the variables below are needed.
*/
bool m_isFirstLine;
+ short m_version;
TQString m_entryFilename;
};