A few code clean up and improvements

Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
pull/1/head
Michele Calgaro 6 years ago
parent 4a66f15d28
commit 4a7a9f41a5
Signed by: MicheleC
GPG Key ID: 2A75B7CA8ADED5CF

@ -67,7 +67,7 @@ void ArchiveFormatInfo::buildFormatInfos()
addFormatInfo( COMPRESSED_FORMAT, "application/x-bzip2", ".bz2" ); addFormatInfo( COMPRESSED_FORMAT, "application/x-bzip2", ".bz2" );
addFormatInfo( COMPRESSED_FORMAT, "application/x-lzip", ".lz" ); addFormatInfo( COMPRESSED_FORMAT, "application/x-lzip", ".lz" );
addFormatInfo( COMPRESSED_FORMAT, "application/x-lzma", ".lzma" ); addFormatInfo( COMPRESSED_FORMAT, "application/x-lzma", ".lzma" );
addFormatInfo( COMPRESSED_FORMAT, "application/x-lzop", ".lzo" ); addFormatInfo( COMPRESSED_FORMAT, "application/x-lzop", ".lzo" );
addFormatInfo( COMPRESSED_FORMAT, "application/x-compress", ".Z" ); addFormatInfo( COMPRESSED_FORMAT, "application/x-compress", ".Z" );
find( COMPRESSED_FORMAT ).description = i18n( "Compressed File" ); find( COMPRESSED_FORMAT ).description = i18n( "Compressed File" );

@ -112,47 +112,46 @@ void CompressedFile::initData()
m_archiver_program = "gzip"; m_archiver_program = "gzip";
m_defaultExtensions << ".gz" << "-gz" << ".z" << "-z" << "_z" << ".Z"; m_defaultExtensions << ".gz" << "-gz" << ".z" << "-z" << "_z" << ".Z";
} }
if ( mimeType == "application/x-bzip" ) else if ( mimeType == "application/x-bzip" )
{ {
m_unarchiver_program = "bunzip"; m_unarchiver_program = "bunzip";
m_archiver_program = "bzip"; m_archiver_program = "bzip";
m_defaultExtensions << ".bz"; m_defaultExtensions << ".bz";
} }
if ( mimeType == "application/x-bzip2" ) else if ( mimeType == "application/x-bzip2" )
{ {
m_unarchiver_program = "bunzip2"; m_unarchiver_program = "bunzip2";
m_archiver_program = "bzip2"; m_archiver_program = "bzip2";
m_defaultExtensions << ".bz2" << ".bz"; m_defaultExtensions << ".bz2" << ".bz";
} }
if (mimeType == "application/x-lzip") { else if ( mimeType == "application/x-lzip" ) {
m_unarchiver_program = "lzip"; m_unarchiver_program = "lzip";
m_archiver_program = "lzip"; m_archiver_program = "lzip";
m_defaultExtensions << ".lz"; m_defaultExtensions << ".lz";
} }
if ( mimeType == "application/x-lzma" ) else if ( mimeType == "application/x-lzma" )
{ {
m_unarchiver_program = "unlzma"; m_unarchiver_program = "unlzma";
m_archiver_program = "lzma"; m_archiver_program = "lzma";
m_defaultExtensions << ".lzma"; m_defaultExtensions << ".lzma";
} }
if ( mimeType == "application/x-xz" ) else if ( mimeType == "application/x-xz" )
{ {
m_unarchiver_program = "unxz"; m_unarchiver_program = "unxz";
m_archiver_program = "xz"; m_archiver_program = "xz";
m_defaultExtensions << ".xz"; m_defaultExtensions << ".xz";
} }
if ( mimeType == "application/x-lzop" ) else if ( mimeType == "application/x-lzop" )
{ m_unarchiver_program = "lzop"; { m_unarchiver_program = "lzop";
m_archiver_program = "lzop"; m_archiver_program = "lzop";
m_defaultExtensions << ".lzo"; m_defaultExtensions << ".lzo";
} }
if ( mimeType == "application/x-compress" ) else if ( mimeType == "application/x-compress" )
{ {
m_unarchiver_program = TDEGlobal::dirs()->findExe( "uncompress" ).isNull()? "gunzip" : "uncompress"; m_unarchiver_program = TDEGlobal::dirs()->findExe( "uncompress" ).isNull()? "gunzip" : "uncompress";
m_archiver_program = "compress"; m_archiver_program = "compress";
m_defaultExtensions = ".Z"; m_defaultExtensions = ".Z";
} }
} }
TQString CompressedFile::extension() TQString CompressedFile::extension()
@ -192,10 +191,10 @@ void CompressedFile::open()
TDEProcess *kp = m_currentProcess = new TDEProcess; TDEProcess *kp = m_currentProcess = new TDEProcess;
kp->clearArguments(); kp->clearArguments();
*kp << m_unarchiver_program << "-f" ; *kp << m_unarchiver_program << "-f" ;
if (m_unarchiver_program == "lzip") { if ( m_unarchiver_program == "lzip" ) {
*kp << "-d"; *kp << "-d";
} }
if ( m_unarchiver_program == "lzop") else if ( m_unarchiver_program == "lzop" )
{ {
*kp << "-d"; *kp << "-d";
// lzop hack, see comment in tar.cpp createTmp() // lzop hack, see comment in tar.cpp createTmp()

@ -184,7 +184,6 @@ void TarArch::updateProgress( TDEProcess * _proc, char *_buffer, int _bufflen )
_proc->kill(); _proc->kill();
KMessageBox::error(0, i18n("Trouble writing to the archive...")); KMessageBox::error(0, i18n("Trouble writing to the archive..."));
kdWarning( 1601 ) << "trouble updating tar archive" << endl; kdWarning( 1601 ) << "trouble updating tar archive" << endl;
//kdFatal( 1601 ) << "trouble updating tar archive" << endl;
} }
} }
@ -198,17 +197,16 @@ TQString TarArch::getCompressor()
if ( m_fileMimeType == "application/x-tgz" ) if ( m_fileMimeType == "application/x-tgz" )
return TQString( "gzip" ); return TQString( "gzip" );
if ( m_fileMimeType == "application/x-tbz" ) if ( m_fileMimeType == "application/x-tbz" )
return TQString( "bzip2" ); return TQString( "bzip2" );
if (m_fileMimeType == "application/x-tlz") { if ( m_fileMimeType == "application/x-tlz" )
return TQString("lzip"); return TQString( "lzip" );
}
if ( m_fileMimeType == "application/x-txz" ) if ( m_fileMimeType == "application/x-txz" )
return TQString( "xz" ); return TQString( "xz" );
if( m_fileMimeType == "application/x-tzo" ) if ( m_fileMimeType == "application/x-tzo" )
return TQString( "lzop" ); return TQString( "lzop" );
return TQString(); return TQString();
@ -223,24 +221,22 @@ TQString TarArch::getUnCompressor()
if ( m_fileMimeType == "application/x-tgz" ) if ( m_fileMimeType == "application/x-tgz" )
return TQString( "gunzip" ); return TQString( "gunzip" );
if ( m_fileMimeType == "application/x-tbz" ) if ( m_fileMimeType == "application/x-tbz" )
return TQString( "bunzip2" ); return TQString( "bunzip2" );
if (m_fileMimeType == "application/x-tlz") { if ( m_fileMimeType == "application/x-tlz" )
return TQString("lzip"); return TQString( "lzip" );
}
if ( m_fileMimeType == "application/x-txz" ) if ( m_fileMimeType == "application/x-txz" )
return TQString( "unxz" ); return TQString( "unxz" );
if( m_fileMimeType == "application/x-tzo" ) if ( m_fileMimeType == "application/x-tzo" )
return TQString( "lzop" ); return TQString( "lzop" );
return TQString(); return TQString();
} }
void void TarArch::open()
TarArch::open()
{ {
if ( compressed ) if ( compressed )
TQFile::remove(tmpfile); // just to make sure TQFile::remove(tmpfile); // just to make sure
@ -396,7 +392,7 @@ void TarArch::createTmp()
if (strUncompressor == "lzip") { if (strUncompressor == "lzip") {
*kp << "-d"; *kp << "-d";
} }
if (strUncompressor == "lzop") else if (strUncompressor == "lzop")
{ {
// setting up a pty for lzop, since it doesn't like stdin to // setting up a pty for lzop, since it doesn't like stdin to
// be /dev/null ( "no filename allowed when reading from stdin" ) // be /dev/null ( "no filename allowed when reading from stdin" )

Loading…
Cancel
Save