@ -46,7 +46,7 @@
# include "../krservices.h"
# include "../Dialogs/krpleasewait.h"
static TQStringList arcProtocols = TQStringList : : split ( " ; " , " tar;bzip;bzip2;gzip;krarc;zip " ) ;
static TQStringList arcProtocols = TQStringList : : split ( " ; " , " tar;bzip;bzip2;gzip;krarc;zip ;xz " ) ;
TDEWallet : : Wallet * KRarcHandler : : wallet = 0 ;
@ -69,6 +69,7 @@ TQStringList KRarcHandler::supportedPackers() {
if ( KrServices : : cmdExist ( " dpkg " ) ) packers . append ( " dpkg " ) ;
if ( KrServices : : cmdExist ( " 7z " ) | | KrServices : : cmdExist ( " 7za " ) ) packers . append ( " 7z " ) ;
if ( KrServices : : cmdExist ( " rpm " ) & & KrServices : : cmdExist ( " rpm2cpio " ) ) packers . append ( " rpm " ) ;
if ( KrServices : : cmdExist ( " xz " ) ) packers . append ( " xz " ) ;
// kdDebug() << "Supported Packers:" << endl;
//TQStringList::Iterator it;
//for( it = packers.begin(); it != packers.end(); ++it )
@ -90,6 +91,8 @@ bool KRarcHandler::arcSupported( TQString type ) {
return true ;
else if ( type = = " -tgz " & & lst . contains ( " tar " ) )
return true ;
else if ( type = = " -txz " & & lst . contains ( " tar " ) )
return true ;
else if ( type = = " tarz " & & lst . contains ( " tar " ) )
return true ;
else if ( type = = " gzip " & & lst . contains ( " gzip " ) )
@ -112,6 +115,8 @@ bool KRarcHandler::arcSupported( TQString type ) {
return true ;
else if ( type = = " -7z " & & lst . contains ( " 7z " ) )
return true ;
else if ( type = = " -xz " & & lst . contains ( " xz " ) )
return true ;
// not supported : (
return false ;
}
@ -125,6 +130,7 @@ bool KRarcHandler::arcHandled( TQString type ) {
( type = = " tarz " & & krConfig - > readBoolEntry ( " Do GZip " , _DoGZip ) ) | |
( type = = " -tar " & & krConfig - > readBoolEntry ( " Do Tar " , _DoTar ) ) | |
( type = = " -tbz " & & krConfig - > readBoolEntry ( " Do BZip2 " , _DoBZip2 ) ) | |
( type = = " -txz " & & krConfig - > readBoolEntry ( " Do Xz " , _DoXz ) ) | |
( type = = " gzip " & & krConfig - > readBoolEntry ( " Do GZip " , _DoGZip ) ) | |
( type = = " zip2 " & & krConfig - > readBoolEntry ( " Do BZip2 " , _DoBZip2 ) ) | |
( type = = " -zip " & & krConfig - > readBoolEntry ( " Do UnZip " , _DoUnZip ) ) | |
@ -135,7 +141,8 @@ bool KRarcHandler::arcHandled( TQString type ) {
( type = = " cpio " & & krConfig - > readBoolEntry ( " Do RPM " , _DoRPM ) ) | |
( type = = " -rpm " & & krConfig - > readBoolEntry ( " Do RPM " , _DoRPM ) ) | |
( type = = " -deb " & & krConfig - > readBoolEntry ( " Do DEB " , _DoDEB ) ) | |
( type = = " -7z " & & krConfig - > readBoolEntry ( " Do 7z " , _Do7z ) ) )
( type = = " -7z " & & krConfig - > readBoolEntry ( " Do 7z " , _Do7z ) ) | |
( type = = " -xz " & & krConfig - > readBoolEntry ( " Do Xz " , _DoXz ) ) )
return true ;
else
return false ;
@ -148,8 +155,8 @@ long KRarcHandler::arcFileCount( TQString archive, TQString type, TQString passw
// first check if supported
if ( ! arcSupported ( type ) ) return 0 ;
// bzip an gzip archive contains only one file
if ( type = = " zip2 " | | type = = " gzip " ) return 1L ;
// bzip , gzip and xz archives contain only one file
if ( type = = " zip2 " | | type = = " gzip " | | type = = " -xz " ) return 1L ;
// set the right lister to do the job
TQString lister ;
@ -159,6 +166,7 @@ long KRarcHandler::arcFileCount( TQString archive, TQString type, TQString passw
else if ( type = = " -tgz " ) lister = KrServices : : fullPathName ( " tar " ) + " -tvzf " ;
else if ( type = = " tarz " ) lister = KrServices : : fullPathName ( " tar " ) + " -tvzf " ;
else if ( type = = " -tbz " ) lister = KrServices : : fullPathName ( " tar " ) + " -tjvf " ;
else if ( type = = " -txz " ) lister = KrServices : : fullPathName ( " tar " ) + " -tJvf " ;
else if ( type = = " -lha " ) lister = KrServices : : fullPathName ( " lha " ) + " l " ;
else if ( type = = " -rar " ) lister = KrServices : : fullPathName ( KrServices : : cmdExist ( " rar " ) ? " rar " : " unrar " ) + " l -v " ;
else if ( type = = " -ace " ) lister = KrServices : : fullPathName ( " unace " ) + " l " ;
@ -171,6 +179,7 @@ long KRarcHandler::arcFileCount( TQString archive, TQString type, TQString passw
else if ( type = = " -rpm " ) lister = KrServices : : fullPathName ( " rpm " ) + " --dump -lpq " ;
else if ( type = = " -deb " ) lister = KrServices : : fullPathName ( " dpkg " ) + " -c " ;
else if ( type = = " -7z " ) lister = KrServices : : fullPathName ( " 7z " ) + " -y l " ;
else if ( type = = " -xz " ) lister = KrServices : : fullPathName ( " xz " ) + " -l " ;
else return 0L ;
if ( ! password . isNull ( ) ) {
@ -241,6 +250,7 @@ bool KRarcHandler::unpack( TQString archive, TQString type, TQString password, T
else if ( type = = " -tgz " ) packer = KrServices : : fullPathName ( " tar " ) + " -xvzf " ;
else if ( type = = " tarz " ) packer = KrServices : : fullPathName ( " tar " ) + " -xvzf " ;
else if ( type = = " -tbz " ) packer = KrServices : : fullPathName ( " tar " ) + " -xjvf " ;
else if ( type = = " -txz " ) packer = KrServices : : fullPathName ( " tar " ) + " -xJvf " ;
else if ( type = = " gzip " ) packer = KrServices : : fullPathName ( " gzip " ) + " -cd " ;
else if ( type = = " zip2 " ) packer = KrServices : : fullPathName ( " bzip2 " ) + " -cdk " ;
else if ( type = = " -lha " ) packer = KrServices : : fullPathName ( " lha " ) + " xf " ;
@ -250,6 +260,7 @@ bool KRarcHandler::unpack( TQString archive, TQString type, TQString password, T
KrServices : : fullPathName ( " arj " ) + " -y -v x " :
KrServices : : fullPathName ( " unarj " ) + " x " ;
else if ( type = = " -7z " ) packer = KrServices : : fullPathName ( " 7z " ) + " -y x " ;
else if ( type = = " -xz " ) packer = KrServices : : fullPathName ( " xz " ) + " -cdk " ;
else if ( type = = " -rpm " ) {
TQString tempDir = locateLocal ( " tmp " , TQString ( ) ) ;
@ -354,6 +365,7 @@ bool KRarcHandler::test( TQString archive, TQString type, TQString password, lon
else if ( type = = " -tgz " ) packer = KrServices : : fullPathName ( " tar " ) + " -tvzf " ;
else if ( type = = " tarz " ) packer = KrServices : : fullPathName ( " tar " ) + " -tvzf " ;
else if ( type = = " -tbz " ) packer = KrServices : : fullPathName ( " tar " ) + " -tjvf " ;
else if ( type = = " -txz " ) packer = KrServices : : fullPathName ( " tar " ) + " -tJvf " ;
else if ( type = = " gzip " ) packer = KrServices : : fullPathName ( " gzip " ) + " -tv " ;
else if ( type = = " zip2 " ) packer = KrServices : : fullPathName ( " bzip2 " ) + " -tv " ;
else if ( type = = " -rar " ) packer = KrServices : : fullPathName ( KrServices : : cmdExist ( " rar " ) ? " rar " : " unrar " ) + " t " ;
@ -362,6 +374,7 @@ bool KRarcHandler::test( TQString archive, TQString type, TQString password, lon
else if ( type = = " -arj " ) packer = KrServices : : fullPathName ( KrServices : : cmdExist ( " arj " ) ? " arj " : " unarj " ) + " t " ;
else if ( type = = " cpio " ) packer = KrServices : : fullPathName ( " cpio " ) + " --only-verify-crc -tvF " ;
else if ( type = = " -7z " ) packer = KrServices : : fullPathName ( " 7z " ) + " -y t " ;
else if ( type = = " -xz " ) packer = KrServices : : fullPathName ( " xz " ) + " -tv " ;
else return false ;
if ( ! password . isNull ( ) ) {
@ -411,10 +424,12 @@ bool KRarcHandler::pack( TQStringList fileNames, TQString type, TQString dest, l
else if ( type = = " tar " ) { packer = KrServices : : fullPathName ( " tar " ) + " -cvf " ; type = " -tar " ; }
else if ( type = = " tar.gz " ) { packer = KrServices : : fullPathName ( " tar " ) + " -cvzf " ; type = " -tgz " ; }
else if ( type = = " tar.bz2 " ) { packer = KrServices : : fullPathName ( " tar " ) + " -cvjf " ; type = " -tbz " ; }
else if ( type = = " tar.xz " ) { packer = KrServices : : fullPathName ( " tar " ) + " -cvJf " ; type = " -txz " ; }
else if ( type = = " rar " ) { packer = KrServices : : fullPathName ( " rar " ) + " -r a " ; type = " -rar " ; }
else if ( type = = " lha " ) { packer = KrServices : : fullPathName ( " lha " ) + " a " ; type = " -lha " ; }
else if ( type = = " arj " ) { packer = KrServices : : fullPathName ( " arj " ) + " -r -y a " ; type = " -arj " ; }
else if ( type = = " 7z " ) { packer = KrServices : : fullPathName ( " 7z " ) + " -y a " ; type = " -7z " ; }
else if ( type = = " xz " ) { packer = KrServices : : fullPathName ( " xz " ) + " -z " ; type = " -xz " ; }
else return false ;
TQString password = TQString ( ) ;
@ -473,6 +488,10 @@ bool KRarcHandler::pack( TQStringList fileNames, TQString type, TQString dest, l
static const int sevenZipLevels [ ] = { 0 , 1 , 2 , 4 , 5 , 6 , 7 , 8 , 9 } ;
packer + = TQString ( " -mx%1 " ) . arg ( sevenZipLevels [ level ] ) ;
}
else if ( type = = " -xz " ) {
static const int xzLevels [ ] = { 0 , 1 , 2 , 4 , 5 , 6 , 7 , 8 , 9 } ;
packer + = TQString ( " -%1 " ) . arg ( xzLevels [ level ] ) ;
}
}
if ( extraProps . count ( " CommandLineSwitches " ) > 0 )
@ -591,7 +610,13 @@ TQString KRarcHandler::getType( bool &encrypted, TQString fileName, TQString mim
result = " - " + result ;
if ( result . endsWith ( " -7z " ) )
{
result = " -7z " ;
}
if ( result . endsWith ( " -xz " ) )
{
result = " -xz " ;
}
return result . right ( 4 ) ;
}
@ -602,9 +627,9 @@ bool KRarcHandler::checkStatus( TQString type, int exitCode ) {
return exitCode = = 0 | | exitCode = = 1 ;
else if ( type = = " -ace " | | type = = " zip2 " | | type = = " -lha " | | type = = " -rpm " | | type = = " cpio " | |
type = = " -tar " | | type = = " tarz " | | type = = " -tbz " | | type = = " -tgz " | | type = = " -arj " | |
type = = " -deb " )
type = = " -deb " | | type = = " -txz " | | type = = " -xz " )
return exitCode = = 0 ;
else if ( type = = " gzip " )
else if ( type = = " gzip " | | type = = " -xz " )
return exitCode = = 0 | | exitCode = = 2 ;
else
return exitCode = = 0 ;
@ -625,7 +650,8 @@ TQString KRarcHandler::detectArchive( bool &encrypted, TQString fileName, bool c
{ " bzip2 " , 0 , " \x42 \x5a \x68 \x39 \x31 " } ,
{ " gzip " , 0 , " \x1f \x8b " } ,
{ " deb " , 0 , " !<arch> \n debian-binary " } ,
{ " 7z " , 0 , " 7z \xbc \xaf \x27 \x1c " } } ;
{ " 7z " , 0 , " 7z \xbc \xaf \x27 \x1c " } ,
{ " xz " , 0 , " \xfd7 zXZ \x00 " } } ;
static int autoDetectElems = sizeof ( autoDetectParams ) / sizeof ( AutoDetectParams ) ;
encrypted = false ;
@ -749,6 +775,16 @@ TQString KRarcHandler::detectArchive( bool &encrypted, TQString fileName, bool c
}
}
}
if ( fileName . endsWith ( " .tar.xz " ) )
{
return " txz " ;
}
else if ( fileName . endsWith ( " .xz " ) )
{
return " xz " ;
}
return TQString ( ) ;
}