Commit 97d1176f authored by Yew Ming Chen's avatar Yew Ming Chen
Browse files

overwrite query for gzipplugin

svn path=/trunk/KDE/kdeutils/ark/; revision=909108
parent 75d6d349
......@@ -55,7 +55,9 @@ namespace Kerfuffle
//---
OverwriteQuery::OverwriteQuery( QString filename) : m_noRenameMode(false)
OverwriteQuery::OverwriteQuery( QString filename) :
m_noRenameMode(false),
m_multiMode(true)
{
m_data["filename"] = filename;
}
......@@ -64,11 +66,15 @@ namespace Kerfuffle
{
QApplication::setOverrideCursor( QCursor( Qt::ArrowCursor ) );
KIO::RenameDialog_Mode mode = (KIO::RenameDialog_Mode)(KIO::M_OVERWRITE | KIO::M_MULTI | KIO::M_SKIP);
KIO::RenameDialog_Mode mode = (KIO::RenameDialog_Mode)(KIO::M_OVERWRITE | KIO::M_SKIP);
if (m_noRenameMode)
{
mode = (KIO::RenameDialog_Mode)(mode | KIO::M_NORENAME);
}
if (m_multiMode)
{
mode = (KIO::RenameDialog_Mode)(mode | KIO::M_MULTI);
}
KIO::RenameDialog dialog(
NULL,
......@@ -128,6 +134,15 @@ namespace Kerfuffle
return m_noRenameMode;
}
void OverwriteQuery::setMultiMode(bool enableMultiMode)
{
m_multiMode = enableMultiMode;
}
bool OverwriteQuery::multiMode()
{
return m_multiMode;
}
PasswordNeededQuery::PasswordNeededQuery(QString archiveFilename, bool incorrectTryAgain)
{
......
......@@ -86,8 +86,11 @@ namespace Kerfuffle
void setNoRenameMode(bool enableNoRenameMode);
bool noRenameMode();
void setMultiMode(bool enableMultiMode);
bool multiMode();
private:
bool m_noRenameMode;
bool m_multiMode;
};
class KERFUFFLE_EXPORT PasswordNeededQuery : public Query
......
......@@ -107,6 +107,32 @@ class LibGzipInterface: public ReadOnlyArchiveInterface
if (gzclose(in) != Z_OK) error("failed gzclose");
}
bool overwriteCheck(QString& filename)
{
while (QFile::exists(filename))
{
Kerfuffle::OverwriteQuery query(filename);
query.setMultiMode(false); // for single file mode
emit userQuery(&query);
query.waitForResponse();
if (query.responseCancelled() || query.responseSkip())
{
return false;
}
else if (query.responseOverwrite())
{
break;
}
else if (query.responseRename())
{
filename = query.newFilename();
}
}
return true;
}
bool copyFiles( const QList<QVariant> & files, const QString & destinationDirectory, ExtractionOptions options )
{
kDebug( 1601 ) ;
......@@ -117,6 +143,8 @@ class LibGzipInterface: public ReadOnlyArchiveInterface
outputFilename += '/';
outputFilename += uncompressedFilename();
if (!overwriteCheck(outputFilename))
return true; // just return as success
FILE *out;
gzFile in;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment