Added support for xz archives. This resolve bug 2516.

Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
feat/lzip-support
Michele Calgaro 9 years ago
parent 76ca48c43d
commit 50e51d1622

@ -125,6 +125,8 @@ KIso::KIso( const TQString& filename, const TQString & _mimetype )
mimetype = "application/x-gzip"; mimetype = "application/x-gzip";
else if ( mimetype == "application/x-tbz" ) // that's a bzipped2 tar file, so ask for bz2 filter else if ( mimetype == "application/x-tbz" ) // that's a bzipped2 tar file, so ask for bz2 filter
mimetype = "application/x-bzip2"; mimetype = "application/x-bzip2";
else if ( mimetype == "application/x-txz" ) // that's a xzipped tar file, so ask for xz filter
mimetype = "application/x-xz";
else else
{ {
// Something else. Check if it's not really gzip though (e.g. for KOffice docs) // Something else. Check if it's not really gzip though (e.g. for KOffice docs)
@ -144,6 +146,14 @@ KIso::KIso( const TQString& filename, const TQString & _mimetype )
if ( fourthByte == 4 ) if ( fourthByte == 4 )
mimetype = "application/x-zip"; mimetype = "application/x-zip";
} }
else if ( firstByte == 0xfd && secondByte == '7' && thirdByte == 'z' )
{
unsigned char fourthByte = file.getch();
unsigned char fifthByte = file.getch();
unsigned char sixthByte = file.getch();
if ( fourthByte == 'X' && fifthByte == 'Z' && sixthByte == 0)
mimetype = "application/x-xz";
}
} }
} }
forced = false; forced = false;
@ -160,8 +170,8 @@ void KIso::prepareDevice( const TQString & filename,
setDevice( new QFileHack( filename ) ); setDevice( new QFileHack( filename ) );
else else
{ {
if( "application/x-gzip" == mimetype if("application/x-gzip" == mimetype || "application/x-bzip2" == mimetype ||
|| "application/x-bzip2" == mimetype) "application/x-xz" == mimetype)
forced = true; forced = true;
TQIODevice *dev = KFilterDev::deviceForFile( filename, mimetype, forced ); TQIODevice *dev = KFilterDev::deviceForFile( filename, mimetype, forced );

@ -313,7 +313,7 @@ void tdeio_krarcProtocol::get(const KURL& url, int tries ){
KMimeType::Ptr mt = KMimeType::findByURL( arcTempDir+file, 0, false /* NOT local URL */ ); KMimeType::Ptr mt = KMimeType::findByURL( arcTempDir+file, 0, false /* NOT local URL */ );
emit mimeType( mt->name() ); emit mimeType( mt->name() );
proc << getCmd << convertName( arcFile->url().path() )+" "; proc << getCmd << convertName( arcFile->url().path() )+" ";
if( arcType != "gzip" && arcType != "bzip2" ) proc << convertFileName( file ); if( arcType != "gzip" && arcType != "bzip2" && arcType != "xz") proc << convertFileName( file );
connect(&proc,TQT_SIGNAL(receivedStdout(TDEProcess*,char*,int)), connect(&proc,TQT_SIGNAL(receivedStdout(TDEProcess*,char*,int)),
this,TQT_SLOT(receivedData(TDEProcess*,char*,int)) ); this,TQT_SLOT(receivedData(TDEProcess*,char*,int)) );
} }
@ -323,7 +323,8 @@ void tdeio_krarcProtocol::get(const KURL& url, int tries ){
proc.start(TDEProcess::Block,TDEProcess::AllOutput); proc.start(TDEProcess::Block,TDEProcess::AllOutput);
if( !extArcReady && !decompressToFile ) { if( !extArcReady && !decompressToFile ) {
if( !proc.normalExit() || !checkStatus( proc.exitStatus() ) || ( arcType != "bzip2" && expectedSize != decompressedLen ) ) { if( !proc.normalExit() || !checkStatus( proc.exitStatus() ) ||
( arcType != "bzip2" && arcType != "xz" && expectedSize != decompressedLen ) ) {
if( encrypted && tries ) { if( encrypted && tries ) {
invalidatePassword(); invalidatePassword();
get( url, tries - 1 ); get( url, tries - 1 );
@ -678,6 +679,8 @@ bool tdeio_krarcProtocol::setArcFile(const KURL& url){
arcType = "bzip2"; arcType = "bzip2";
else if( arcType == "tgz" ) else if( arcType == "tgz" )
arcType = "gzip"; arcType = "gzip";
else if( arcType == "txz" )
arcType = "xz";
if( arcType.isEmpty() ) { if( arcType.isEmpty() ) {
arcType = arcFile->mimetype(); arcType = arcFile->mimetype();
@ -704,7 +707,7 @@ bool tdeio_krarcProtocol::initDirDict(const KURL&url, bool forced){
KrShellProcess proc; KrShellProcess proc;
KTempFile temp( TQString(), "tmp" ); KTempFile temp( TQString(), "tmp" );
temp.setAutoDelete(true); temp.setAutoDelete(true);
if( arcType != "bzip2" ){ if (arcType != "bzip2" && arcType != "xz") {
if( arcType == "rpm" ) if( arcType == "rpm" )
proc << listCmd << convertName( arcPath ) <<" > " << temp.name(); proc << listCmd << convertName( arcPath ) <<" > " << temp.name();
else else
@ -736,7 +739,7 @@ bool tdeio_krarcProtocol::initDirDict(const KURL&url, bool forced){
root->append(entry); root->append(entry);
if( arcType == "bzip2" ){ if (arcType == "bzip2" || arcType == "xz"){
KRDEBUG("Got me here..."); KRDEBUG("Got me here...");
parseLine(0,"",temp.file()); parseLine(0,"",temp.file());
return true; return true;
@ -1158,6 +1161,14 @@ void tdeio_krarcProtocol::parseLine(int lineNo, TQString line, TQFile*) {
// full name // full name
fullName = nextWord(line,'\n'); fullName = nextWord(line,'\n');
} }
if (arcType == "xz") {
fullName = arcFile->name();
if (fullName.endsWith("xz")) {
fullName.truncate(fullName.length() - 3);
}
mode = arcFile->mode();
size = arcFile->size();
}
if( fullName.right(1) == "/" ) fullName = fullName.left(fullName.length()-1); if( fullName.right(1) == "/" ) fullName = fullName.left(fullName.length()-1);
if( !fullName.startsWith("/") ) fullName = "/"+fullName; if( !fullName.startsWith("/") ) fullName = "/"+fullName;
@ -1356,8 +1367,14 @@ bool tdeio_krarcProtocol::initArcParameters() {
delCmd += "-p'"+password+"' "; delCmd += "-p'"+password+"' ";
} }
} }
} } else if (arcType == "xz") {
else { cmd = fullPathName("xz");
listCmd = fullPathName("xz");
getCmd = fullPathName("xz") + "-dc";
copyCmd = TQString();
delCmd = TQString();
putCmd = TQString();
} else {
cmd = TQString(); cmd = TQString();
listCmd = TQString(); listCmd = TQString();
getCmd = TQString(); getCmd = TQString();
@ -1383,7 +1400,7 @@ bool tdeio_krarcProtocol::checkStatus( int exitCode ) {
return exitCode == 0 || exitCode == 1; return exitCode == 0 || exitCode == 1;
else if( arcType == "ace" || arcType == "bzip2" || arcType == "lha" || arcType == "rpm" || arcType == "arj" ) else if( arcType == "ace" || arcType == "bzip2" || arcType == "lha" || arcType == "rpm" || arcType == "arj" )
return exitCode == 0; return exitCode == 0;
else if( arcType == "gzip" ) else if( arcType == "gzip"|| arcType == "xz" )
return exitCode == 0 || exitCode == 2; return exitCode == 0 || exitCode == 2;
else else
return exitCode == 0; return exitCode == 0;
@ -1404,7 +1421,8 @@ TQString tdeio_krarcProtocol::detectArchive( bool &encrypted, TQString fileName
{"bzip2",0, "\x42\x5a\x68\x39\x31" }, {"bzip2",0, "\x42\x5a\x68\x39\x31" },
{"gzip", 0, "\x1f\x8b"}, {"gzip", 0, "\x1f\x8b"},
{"deb", 0, "!<arch>\ndebian-binary " }, {"deb", 0, "!<arch>\ndebian-binary " },
{"7z", 0, "7z\xbc\xaf\x27\x1c" } }; {"7z", 0, "7z\xbc\xaf\x27\x1c" },
{"xz", 0, "\xfd7zXZ\x00"} };
static int autoDetectElems = sizeof( autoDetectParams ) / sizeof( AutoDetectParams ); static int autoDetectElems = sizeof( autoDetectParams ) / sizeof( AutoDetectParams );
encrypted = false; encrypted = false;
@ -1545,6 +1563,16 @@ TQString tdeio_krarcProtocol::detectArchive( bool &encrypted, TQString fileName
} }
} }
} }
if (fileName.endsWith(".tar.xz"))
{
return "txz";
}
else if (fileName.endsWith(".xz"))
{
return "xz";
}
return TQString(); return TQString();
} }

@ -63,11 +63,13 @@ PackGUI::PackGUI(TQString defaultName, TQString defaultPath, int noOfFiles, TQSt
if (PS("tar")) typeData->insertItem("tar"); if (PS("tar")) typeData->insertItem("tar");
if (PS("tar") && PS("gzip")) typeData->insertItem("tar.gz"); if (PS("tar") && PS("gzip")) typeData->insertItem("tar.gz");
if (PS("tar") && PS("bzip2")) typeData->insertItem("tar.bz2"); if (PS("tar") && PS("bzip2")) typeData->insertItem("tar.bz2");
if (PS("tar") && PS("xz")) typeData->insertItem("tar.xz");
if (PS("zip")) typeData->insertItem("zip"); if (PS("zip")) typeData->insertItem("zip");
if (PS("rar")) typeData->insertItem("rar"); if (PS("rar")) typeData->insertItem("rar");
if (PS("lha")) typeData->insertItem("lha"); if (PS("lha")) typeData->insertItem("lha");
if (PS("arj")) typeData->insertItem("arj"); if (PS("arj")) typeData->insertItem("arj");
if (PS("7z")) typeData->insertItem("7z"); if (PS("7z")) typeData->insertItem("7z");
if (PS("xz")) typeData->insertItem("xz");
// set the last used packer as the top one // set the last used packer as the top one
TQString tmp=krConfig->readEntry("lastUsedPacker",TQString()); TQString tmp=krConfig->readEntry("lastUsedPacker",TQString());
if (tmp!=TQString()) { if (tmp!=TQString()) {

@ -66,10 +66,11 @@ KgArchives::KgArchives( bool first, TQWidget* parent, const char* name ) :
{"Archives","Do UnAce", _DoUnAce, i18n( "Ace" ), false, ""}, {"Archives","Do UnAce", _DoUnAce, i18n( "Ace" ), false, ""},
{"Archives","Do Lha", _DoLha, i18n( "Lha" ), false, ""}, {"Archives","Do Lha", _DoLha, i18n( "Lha" ), false, ""},
{"Archives","Do DEB", _DoDEB, i18n( "Deb" ), false, ""}, {"Archives","Do DEB", _DoDEB, i18n( "Deb" ), false, ""},
{"Archives","Do 7z", _Do7z, i18n( "7zip" ), false, ""} {"Archives","Do 7z", _Do7z, i18n( "7zip" ), false, ""},
{"Archives","Do Xz", _DoXz, i18n( "Xz" ), false, ""}
}; };
cbs = createCheckBoxGroup( 3, 0, packers, 11, generalGrp ); cbs = createCheckBoxGroup( 3, 0, packers, 12, generalGrp );
generalGrid->addWidget( cbs, 1, 0 ); generalGrid->addWidget( cbs, 1, 0 );
addLabel( generalGrid, 2, 0, i18n( "The archives that are \"greyed-out\" were unavailable on your\nsystem last time Krusader checked. If you wish Krusader to\nsearch again, click the 'Auto Configure' button." ), addLabel( generalGrid, 2, 0, i18n( "The archives that are \"greyed-out\" were unavailable on your\nsystem last time Krusader checked. If you wish Krusader to\nsearch again, click the 'Auto Configure' button." ),
@ -133,6 +134,7 @@ void KgArchives::disableNonExistingPackers()
cbs->find( "Do Unarj" )->setEnabled(PS("unarj") || PS("arj") ); cbs->find( "Do Unarj" )->setEnabled(PS("unarj") || PS("arj") );
cbs->find( "Do DEB" )->setEnabled(PS("dpkg") && PS("tar") ); cbs->find( "Do DEB" )->setEnabled(PS("dpkg") && PS("tar") );
cbs->find( "Do 7z" )->setEnabled( PS("7z") ); cbs->find( "Do 7z" )->setEnabled( PS("7z") );
cbs->find( "Do Xz" )->setEnabled(PS("xz"));
krConfig->setGroup( "Archives" ); krConfig->setGroup( "Archives" );
krConfig->writeEntry( "Supported Packers", lst ); krConfig->writeEntry( "Supported Packers", lst );

@ -93,6 +93,7 @@ KgDependencies::KgDependencies( bool first, TQWidget* parent, const char* name
addApplication( "unrar", archGrid1,11, packers_tab, PAGE_PACKERS ); addApplication( "unrar", archGrid1,11, packers_tab, PAGE_PACKERS );
addApplication( "unzip", archGrid1,12, packers_tab, PAGE_PACKERS ); addApplication( "unzip", archGrid1,12, packers_tab, PAGE_PACKERS );
addApplication( "zip", archGrid1,13, packers_tab, PAGE_PACKERS ); addApplication( "zip", archGrid1,13, packers_tab, PAGE_PACKERS );
addApplication( "xz", archGrid1,14, packers_tab, PAGE_PACKERS );
// ---------------------------- CHECKSUM TAB ------------------------------------- // ---------------------------- CHECKSUM TAB -------------------------------------
TQWidget *checksum_tab = new TQWidget( tabWidget, "tab_4" ); TQWidget *checksum_tab = new TQWidget( tabWidget, "tab_4" );

@ -132,6 +132,7 @@ TQFrame *line2 = createLine( generalGrp, "line2" );
defaultAtomicExtensions += ".tar.gz"; defaultAtomicExtensions += ".tar.gz";
defaultAtomicExtensions += ".tar.bz2"; defaultAtomicExtensions += ".tar.bz2";
defaultAtomicExtensions += ".moc.cpp"; defaultAtomicExtensions += ".moc.cpp";
defaultAtomicExtensions += ".tar.xz";
listBox = createListBox( "Look&Feel", "Atomic Extensions", listBox = createListBox( "Look&Feel", "Atomic Extensions",
defaultAtomicExtensions, vbox2, true, false ); defaultAtomicExtensions, vbox2, true, false );

@ -51,10 +51,11 @@ TQString KgProtocols::defaultKrarcMimes = "application/x-7z,application/x-7z-com
"application/x-lha,application/x-lha-compressed," "application/x-lha,application/x-lha-compressed,"
"application/x-rar,application/x-rar-compressed," "application/x-rar,application/x-rar-compressed,"
"application/x-rpm," "application/x-rpm,"
"application/x-xz,"
"application/x-zip,application/x-zip-compressed"; "application/x-zip,application/x-zip-compressed";
TQString KgProtocols::defaultTarMimes = "application/x-tar,application/x-tarz," TQString KgProtocols::defaultTarMimes = "application/x-tar,application/x-tarz,"
"application/x-compressed-tar," "application/x-compressed-tar,"
"application/x-tbz,application/x-tgz"; "application/x-tbz,application/x-tgz,application/x-txz";
KgProtocols::KgProtocols( bool first, TQWidget* parent, const char* name ) : KgProtocols::KgProtocols( bool first, TQWidget* parent, const char* name ) :
KonfiguratorPage( first, parent, name ) KonfiguratorPage( first, parent, name )

@ -113,6 +113,7 @@ KrArchiverResultTable::KrArchiverResultTable(TQWidget* parent)
Archiver* rpm = new Archiver("rpm", "http://www.gnu.org", PS("rpm"), false, true); Archiver* rpm = new Archiver("rpm", "http://www.gnu.org", PS("rpm"), false, true);
Archiver* dpkg = new Archiver("dpkg", "http://www.dpkg.org", PS("dpkg"), false, true); Archiver* dpkg = new Archiver("dpkg", "http://www.dpkg.org", PS("dpkg"), false, true);
Archiver* _7z = new Archiver("7z", "http://www.7-zip.org", PS("7z"), true, true); Archiver* _7z = new Archiver("7z", "http://www.7-zip.org", PS("7z"), true, true);
Archiver* xz = new Archiver("xz", "http://www.tukaani.org/xz", PS("xz"), true, true);
// Special case: arj can unpack, but unarj is prefered // Special case: arj can unpack, but unarj is prefered
if(PS("arj") && PS("unarj")) if(PS("arj") && PS("unarj"))
@ -149,6 +150,7 @@ KrArchiverResultTable::KrArchiverResultTable(TQWidget* parent)
addRow(rpm, _grid); addRow(rpm, _grid);
addRow(dpkg, _grid); addRow(dpkg, _grid);
addRow(_7z, _grid); addRow(_7z, _grid);
addRow(xz, _grid);
delete tar; delete tar;
delete gzip; delete gzip;
@ -164,6 +166,7 @@ KrArchiverResultTable::KrArchiverResultTable(TQWidget* parent)
delete rpm; delete rpm;
delete dpkg; delete dpkg;
delete _7z; delete _7z;
delete xz;
} }
KrArchiverResultTable::~KrArchiverResultTable() KrArchiverResultTable::~KrArchiverResultTable()

@ -1319,6 +1319,7 @@ void KrBriefView::initProperties() {
defaultAtomicExtensions += ".tar.gz"; defaultAtomicExtensions += ".tar.gz";
defaultAtomicExtensions += ".tar.bz2"; defaultAtomicExtensions += ".tar.bz2";
defaultAtomicExtensions += ".moc.cpp"; defaultAtomicExtensions += ".moc.cpp";
defaultAtomicExtensions += ".tar.xz";
TQStringList atomicExtensions = krConfig->readListEntry("Atomic Extensions", defaultAtomicExtensions); TQStringList atomicExtensions = krConfig->readListEntry("Atomic Extensions", defaultAtomicExtensions);
for (TQStringList::iterator i = atomicExtensions.begin(); i != atomicExtensions.end(); ) for (TQStringList::iterator i = atomicExtensions.begin(); i != atomicExtensions.end(); )
{ {

@ -1414,6 +1414,7 @@ void KrDetailedView::initProperties() {
defaultAtomicExtensions += ".tar.gz"; defaultAtomicExtensions += ".tar.gz";
defaultAtomicExtensions += ".tar.bz2"; defaultAtomicExtensions += ".tar.bz2";
defaultAtomicExtensions += ".moc.cpp"; defaultAtomicExtensions += ".moc.cpp";
defaultAtomicExtensions += ".tar.xz";
TQStringList atomicExtensions = krConfig->readListEntry("Atomic Extensions", defaultAtomicExtensions); TQStringList atomicExtensions = krConfig->readListEntry("Atomic Extensions", defaultAtomicExtensions);
for (TQStringList::iterator i = atomicExtensions.begin(); i != atomicExtensions.end(); ) for (TQStringList::iterator i = atomicExtensions.begin(); i != atomicExtensions.end(); )
{ {

@ -12,6 +12,7 @@ TQString atomicExtensions[] = {
".tar.gz", ".tar.gz",
".tar.bz2", ".tar.bz2",
".moc.cpp" ".moc.cpp"
".tar.xz",
}; };
KrViewItem::KrViewItem(vfile *vf, const KrViewProperties* properties): KrViewItem::KrViewItem(vfile *vf, const KrViewProperties* properties):

@ -721,7 +721,6 @@ void ListPanelFunc::execute( TQString& name ) {
dirUp(); dirUp();
return ; return ;
} }
vfile *vf = files() ->vfs_search( name ); vfile *vf = files() ->vfs_search( name );
if ( vf == 0 ) if ( vf == 0 )
return ; return ;
@ -729,7 +728,6 @@ void ListPanelFunc::execute( TQString& name ) {
KURL origin = files() ->vfs_getOrigin(); KURL origin = files() ->vfs_getOrigin();
TQString protocol = origin.isLocalFile() ? KrServices::registerdProtocol( vf->vfile_getMime() ) : ""; TQString protocol = origin.isLocalFile() ? KrServices::registerdProtocol( vf->vfile_getMime() ) : "";
if ( protocol == "tar" || protocol == "krarc" ) { if ( protocol == "tar" || protocol == "krarc" ) {
bool encrypted; bool encrypted;
TQString type = KRarcHandler::getType( encrypted, vf->vfile_getUrl().path(), vf->vfile_getMime(), false ); TQString type = KRarcHandler::getType( encrypted, vf->vfile_getUrl().path(), vf->vfile_getMime(), false );

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

@ -189,8 +189,10 @@
#define _DoDEB true #define _DoDEB true
// Do Lha ///////////// // Do Lha /////////////
#define _DoLha true #define _DoLha true
// Do 7z ///////////// ====> new // Do 7z ////////////// ====> new
#define _Do7z true #define _Do7z true
// Do Xz //////////////
#define _DoXz true
// Allow Move Into Archive // // Allow Move Into Archive //
#define _MoveIntoArchive false #define _MoveIntoArchive false
// Test Archives ////// // Test Archives //////

@ -459,6 +459,21 @@ bool Krusader::versionControl() {
} }
config->writeEntry( "Version", VERSION ); config->writeEntry( "Version", VERSION );
config->writeEntry( FIRST_RUN, false); config->writeEntry( FIRST_RUN, false);
// Check whether Krusader is run for the first time under a new TDE version.
TQString lastVersion = config->readEntry("Last version");
if (lastVersion != TDE_VERSION_STRING)
{
config->writeEntry("Last version", TDE_VERSION_STRING);
if (!retval)
{
KMessageBox::information(krApp, i18n( "<qt><b>Welcome to Krusader!</b><p>As this is your first run "
"under TDE " TDE_VERSION_STRING ", your machine will now be checked for external applications updates. "
"Then the Konfigurator will be launched where you can customize Krusader to your needs.</p></qt>" ) );
}
retval = true;
}
config->sync(); config->sync();
return retval; return retval;
} }

Loading…
Cancel
Save