[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: kdenonbeta/karchiver
From: Eric Coquelle <eric.coquelle () gmail ! com>
Date: 2006-09-12 20:35:38
Message-ID: 1158093338.957020.30041.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 583626 by coquelle:
Added new functions that allow to better detect errors in Zip, Rar, Lha and 7z \
archives. Also, when an archive is checked for errors, one can repair damaged Rar and \
Zip archives
M +2 -0 ChangeLog
M +11 -2 c7z.cpp
M +3 -1 c7z.h
M +9 -0 carchive.h
M +31 -4 carchiveoperation.cpp
M +2 -0 carchiveoperation.h
M +9 -0 clha.cpp
M +2 -0 clha.h
M +19 -0 crar.cpp
M +4 -0 crar.h
M +28 -2 czip.cpp
M +6 -0 czip.h
M +1 -1 karchiveur.cpp
--- trunk/kdenonbeta/karchiver/ChangeLog #583625:583626
@@ -8,6 +8,8 @@
Added Zip comments support
Added a connection to an anti-virus scanner
Added a little animation while an archive is read
+Added possibility to repair damaged archives
+Improved the Test Archive module
Improved the CheckForUpdates component
Improved the Compilation & Installation wizard
Improved support of Sit archives
--- trunk/kdenonbeta/karchiver/c7z.cpp #583625:583626
@@ -385,8 +385,8 @@
processadd.start(KProcess::NotifyOnExit);
}
-/** Create a zip archive
-@param nameofarchive: the name of the zip archive
+/** Create a 7zip archive
+@param nameofarchive: the name of the 7zip archive
@param param: list of files to add
@param relativepath: include only filenames, without their path */
void C7z::createArchive(QString nameofarchive, QStringList filestoadd, QString \
relativepath) { @@ -403,4 +403,13 @@
}
+/** perform an integrity check...*/
+void C7z::testCurrentArchiveIntegrity()
+{
+ processextract.clearArguments();
+ processextract << "7za" << "t" << archiveName;
+ processextract.start(KProcess::NotifyOnExit,KProcess::AllOutput);
+}
+
+
#include "c7z.moc"
--- trunk/kdenonbeta/karchiver/c7z.h #583625:583626
@@ -55,7 +55,9 @@
void createArchive(QString nameofarchive, QStringList filestoadd, QString \
relativepath=NULL); /** Returns true if archive type supports passwords */
bool supportPassword();
-
+ /**Check integrity of current archive*/
+ void testCurrentArchiveIntegrity();
+
protected: // Protected methods
/** display in a listview the content of the current
* zip archive. This method examines the stdout of
--- trunk/kdenonbeta/karchiver/carchive.h #583625:583626
@@ -88,7 +88,10 @@
virtual void removeFilesFromArchive(QStringList filesToDelete);
virtual void addFilesToArchive( QStringList filestoadd, bool removeoriginalfiles, \
int action, QString relativepath=NULL); virtual void createArchive(QString \
nameofarchive, QStringList filestoadd, QString relativepath=NULL); + virtual void \
repairCurrentArchive(){}; + virtual void testCurrentArchiveIntegrity(){emit \
archiveReadEnded();};
+
/** set the name of the working archive to @param archName */
void setArchiveName( QString archName );
QString getArchiveName();
@@ -121,8 +124,12 @@
virtual bool supportDisplayByDirs(){return false;};
/**Returns true if archive type supports passwords*/
virtual bool supportPassword(){return false;};
+ /**Returns true if current archive can be repaired*/
+ virtual bool canRepairArchive(){return false;};
/** Returns the password */
QCString getPassword();
+ /**Returns the name of the repaired archive*/
+ QString getRepairedArchiveName(){return repairedArchiveName;};
/**Returns the numbers of files in current archive*/
int countFiles();
/**Get some infos on current archive (size, compress rate...)*/
@@ -221,6 +228,8 @@
int issourcesoftware;
bool lookforsoucearchive;
enum sourcesoftwareflags {HAS_CONFIGURE=2, HAS_MAKEFILE_AM=4};
+ /**The name of a repaired archives*/
+ QString repairedArchiveName;
};
#endif
--- trunk/kdenonbeta/karchiver/carchiveoperation.cpp #583625:583626
@@ -1017,7 +1017,6 @@
void CArchiveOperationSfx::cat()
{
int j;
- int MaxL;
QFile filesfx(exearchivename);
filesfx.open(IO_WriteOnly | IO_Append);
@@ -1063,11 +1062,30 @@
void CArchiveOperationTest::slotExtractProcessEnded()
{
disconnect(archiveobj, SIGNAL(archiveReadEnded()), this, \
SLOT(slotExtractProcessEnded()));
-
+ connect(archiveobj, SIGNAL(archiveReadEnded()), this, \
SLOT(slotIntegrityProcessEnded())); + archiveobj->testCurrentArchiveIntegrity();
+}
+
+void CArchiveOperationTest::slotIntegrityProcessEnded()
+{
+ disconnect(archiveobj, SIGNAL(archiveReadEnded()), this, \
SLOT(slotIntegrityProcessEnded())); if(!archiveobj->getErrors().isEmpty())
{
- KMessageBox::informationList(0,i18n("Some errors occurred while extracting this \
archive:"),archiveobj->getErrors());
- emit(operationEnded(CANNOT_PERFORM_OPERATION, i18n("Some errors occurred while \
extracting this archive:"))); + if( KMessageBox::questionYesNoList(0,i18n("Some \
errors occurred while testing this archive. Would you like to repair this archive \
?"),archiveobj->getErrors()) == KMessageBox::Yes ) + {
+ if(archiveobj->canRepairArchive())
+ {
+ connect(archiveobj, SIGNAL(archiveReadEnded()), this, \
SLOT(archiveRepaired())); + archiveobj->repairCurrentArchive();
+ }
+ else
+ {
+ KMessageBox::error(0, i18n("This compressor cannot repair damaged \
archives"), i18n("Not possible")); + emit \
operationEnded(CANNOT_PERFORM_OPERATION, i18n("This compressor cannot repair damaged \
archives")); + }
+ }
+ else
+ emit(operationEnded(CANNOT_PERFORM_OPERATION, i18n("Some errors occurred while \
extracting this archive:"))); }
else
{
@@ -1076,8 +1094,17 @@
}
}
+void CArchiveOperationTest::archiveRepaired()
+{
+ disconnect(archiveobj, SIGNAL(archiveReadEnded()), this, SLOT(archiveRepaired()));
+
+ KMessageBox::informationList(0, i18n("<qt>The archive <i>%1</i> has been \
repaired.<br>During the reparation, the following errors \
occured:</qt>").arg(archiveobj->getRepairedArchiveName()), archiveobj->getErrors(), \
i18n("Repair of archives")); +
+ emit operationEnded(TEST_ACHIEVED, i18n("Archive repaired"));
+}
+
//////////////////////////////////////////////////////////////////////////////////////
/**The CArchiveOperationScanForVirus class
* extracts the content of current archive to @param temp_dir
--- trunk/kdenonbeta/karchiver/carchiveoperation.h #583625:583626
@@ -298,6 +298,8 @@
protected slots:
void slotExtractProcessEnded();
+ void slotIntegrityProcessEnded();
+ void archiveRepaired();
};
--- trunk/kdenonbeta/karchiver/clha.cpp #583625:583626
@@ -362,4 +362,13 @@
kdDebug()<<("\nEndCreateLha\n");
}
+/** perform an integrity check...*/
+void CLha::testCurrentArchiveIntegrity()
+{
+ processextract.clearArguments();
+ processextract << "lha" << "t" << archiveName;
+ processextract.start(KProcess::NotifyOnExit,KProcess::AllOutput);
+}
+
+
#include "clha.moc"
--- trunk/kdenonbeta/karchiver/clha.h #583625:583626
@@ -52,6 +52,8 @@
@param action : 0=mode append and replace files, 1=mode update files
@param relativepath : if !NULL, include only filenames, without their base path */
void addFilesToArchive( QStringList filestoadd, bool removeoriginalfiles, int \
action, QString relativepath); + /** perform an integrity check...*/
+ void testCurrentArchiveIntegrity();
protected: // Protected methods
--- trunk/kdenonbeta/karchiver/crar.cpp #583625:583626
@@ -450,5 +450,24 @@
}
}
+/**Returns true if current archive can be repaired*/
+bool CRar::canRepairArchive(){
+ return true;
+}
+/**Launches the repair process*/
+void CRar::repairCurrentArchive()
+{
+ QFileInfo archive(archiveName);
+ errors.clear();
+
+ repairedArchiveName=archive.dirPath(true)+"/"+"rebuilt."+archive.fileName();
+ QDir::setCurrent(archive.dirPath(true));
+
+ processextract.clearArguments();
+ processextract << "rar" << "r" << "-y" << archiveName;
+ processextract.start(KProcess::NotifyOnExit,KProcess::AllOutput);
+}
+
+
#include "crar.moc"
--- trunk/kdenonbeta/karchiver/crar.h #583625:583626
@@ -56,6 +56,10 @@
void addFilesToArchive( QStringList filestoadd, bool removeoriginalfiles, int \
action, QString relativepath=NULL); /** Returns true if archive type supports \
passwords */ bool supportPassword();
+ /**Returns true if current archive can be repaired*/
+ bool canRepairArchive();
+ /**Launches the repair process*/
+ void repairCurrentArchive();
protected: // Protected methods
/** display in a listview the content of the current
--- trunk/kdenonbeta/karchiver/czip.cpp #583625:583626
@@ -60,7 +60,7 @@
{
zipfile=new KZip(archiveName);
if( !zipfile->open(IO_ReadOnly) )
- errors.append("Process failed to open file");
+ errors.append("KZip Process failed to open file");
CArchive::displayArchiveContent(zipfile->directory(),QString::null);
endProcess(NULL);
@@ -468,7 +468,33 @@
/** Returns true if archive type supports passwords */
bool CZip::supportPassword(){
return true;
-
}
+/**Returns true if current archive can be repaired*/
+bool CZip::canRepairArchive(){
+ return true;
+}
+
+/**Launches the repair process*/
+void CZip::repairCurrentArchive()
+{
+ errors.clear();
+
+ repairedArchiveName=archiveName;
+ QDir::setCurrent(QFileInfo(archiveName).dirPath(true));
+
+ processextract.clearArguments();
+ processextract << "zip" << "-FF" << archiveName;
+ processextract.start(KProcess::NotifyOnExit,KProcess::AllOutput);
+}
+
+/** unzip don't dosplay any error when extracting some damaged archives, so
+ * perform an integrity check...*/
+void CZip::testCurrentArchiveIntegrity()
+{
+ processextract.clearArguments();
+ processextract << "zip" << "-T" << archiveName;
+ processextract.start(KProcess::NotifyOnExit,KProcess::AllOutput);
+}
+
#include "czip.moc"
--- trunk/kdenonbeta/karchiver/czip.h #583625:583626
@@ -59,6 +59,12 @@
bool supportDisplayByDirs(){return true;};
/** Returns true if archive type supports passwords */
bool supportPassword();
+ /**Returns true if current archive can be repaired*/
+ bool canRepairArchive();
+ /**Launches the repair process*/
+ void repairCurrentArchive();
+ /**Check integrity of current archive*/
+ void testCurrentArchiveIntegrity();
protected: // Protected methods
/** display in a listview the content of the current
--- trunk/kdenonbeta/karchiver/karchiveur.cpp #583625:583626
@@ -1743,7 +1743,7 @@
archiveWizard=new KAction(i18n("Launch the &Wizard"), "wizard", 0, this, SLOT( \
slotWizard()), actionCollection(),"archive_wizard" ); archiveProprieties=new \
KAction(i18n("&Properties"), 0, this, SLOT( slotDisplayFileProprieties()), \
actionCollection(),"archive_proprieties" ); archiveScan=new KAction( i18n("&Scan for \
viruses"), "find", 0, this, SLOT( slotScanArchive()), \
actionCollection(),"archive_scan" );
- archiveTest=new KAction(i18n("&Test Archive"), "documentinfo", 0, this, SLOT( \
slotTestArchive()), actionCollection(),"archive_test" ); + archiveTest=new \
KAction(i18n("&Test and repair Archive"), "documentinfo", 0, this, SLOT( \
slotTestArchive()), actionCollection(),"archive_test" );
///////////////////////////////////////////////////////////////////
// menuBar entry editMenu
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic