From ffcb34f4b88f6e3974d45d6c2b91d68ef051e917 Mon Sep 17 00:00:00 2001 From: tpearson Date: Tue, 17 Aug 2010 17:54:01 +0000 Subject: Preliminary xzip/LZMA support git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdelibs@1164814 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- kio/kio/ktar.cpp | 14 ++++++++++++-- kio/kio/ktar.h | 5 +++-- 2 files changed, 15 insertions(+), 4 deletions(-) (limited to 'kio') diff --git a/kio/kio/ktar.cpp b/kio/kio/ktar.cpp index cf4bade20..e5173fdbc 100644 --- a/kio/kio/ktar.cpp +++ b/kio/kio/ktar.cpp @@ -101,6 +101,14 @@ KTar::KTar( const TQString& filename, const TQString & _mimetype ) if ( fourthByte == 4 ) mimetype = "application/x-zip"; } + else if ( firstByte == '\xFD' && 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 == 0x00 ) + mimetype = "application/x-xz"; + } } file.close(); } @@ -285,8 +293,10 @@ bool KTar::KTarPrivate::fillTempFile( const TQString & filename) { bool forced = false; if( "application/x-gzip" == mimetype - || "application/x-bzip2" == mimetype) - forced = true; + || "application/x-bzip2" == mimetype + || "application/x-lzma" == mimetype + || "application/x-xz" == mimetype) + forced = true; TQIODevice *filterDev = KFilterDev::deviceForFile( filename, mimetype, forced ); diff --git a/kio/kio/ktar.h b/kio/kio/ktar.h index 915cfed3a..95c52a32c 100644 --- a/kio/kio/ktar.h +++ b/kio/kio/ktar.h @@ -33,7 +33,7 @@ * A class for reading / writing (optionally compressed) tar archives. * * KTar allows you to read and write tar archives, including those - * that are compressed using gzip or bzip2. + * that are compressed using gzip, bzip2, or xz. * * @author Torben Weis , David Faure */ @@ -45,7 +45,8 @@ public: * using the compression filter associated to given mimetype. * * @param filename is a local path (e.g. "/home/weis/myfile.tgz") - * @param mimetype "application/x-gzip" or "application/x-bzip2" + * @param mimetype "application/x-gzip", "application/x-bzip2", + * or "application/x-xz" * Do not use application/x-tgz or similar - you only need to * specify the compression layer ! If the mimetype is omitted, it * will be determined from the filename. -- cgit v1.2.1