From 9655fa99578680d2e126dddfc6871c2504e34b13 Mon Sep 17 00:00:00 2001 From: Ivan Ilin Date: Mon, 5 Dec 2011 16:02:15 +0200 Subject: [PATCH] Quazip relative bug fixed --- src/adaptors/UBImportCFF.cpp | 65 +++++++++++++++--------------------- 1 file changed, 26 insertions(+), 39 deletions(-) diff --git a/src/adaptors/UBImportCFF.cpp b/src/adaptors/UBImportCFF.cpp index d4059982..448e2834 100644 --- a/src/adaptors/UBImportCFF.cpp +++ b/src/adaptors/UBImportCFF.cpp @@ -178,45 +178,32 @@ QString UBImportCFF::expandFileToDir(const QFile& pZipFile, const QString& pDir) } QString newFileName = documentRootFolder + "/" + file.getActualFileName(); - bool ends = newFileName.endsWith('/'); - if (!ends) { - - QFileInfo newFileInfo(newFileName); - rootDir.mkpath(newFileInfo.absolutePath()); - - out.setFileName(newFileName); - out.open(QIODevice::WriteOnly); - - // Slow like hell (on GNU/Linux at least), but it is not my fault. - // Not ZIP/UNZIP package's fault either. - // The slowest thing here is out.putChar(c). - QByteArray outFileContent = file.readAll(); - if (out.write(outFileContent) == -1) - { - qWarning() << "Import failed. Cause: Unable to write file"; - out.close(); - return ""; - } - while(file.getChar(&c)) - out.putChar(c); - - out.close(); - - if(file.getZipError()!=UNZ_OK) { - qWarning() << "Import failed. Cause: " << zip.getZipError(); - return ""; - } - if(!file.atEnd()) { - qWarning() << "Import failed. Cause: read all but not EOF"; - return ""; - } - - file.close(); - - if(file.getZipError()!=UNZ_OK) { - qWarning() << "Import failed. Cause: file.close(): " << file.getZipError(); - return ""; - } + + QFileInfo newFileInfo(newFileName); + rootDir.mkpath(newFileInfo.absolutePath()); + + out.setFileName(newFileName); + out.open(QIODevice::WriteOnly); + + while(file.getChar(&c)) + out.putChar(c); + + out.close(); + + if(file.getZipError()!=UNZ_OK) { + qWarning() << "Import failed. Cause: " << zip.getZipError(); + return ""; + } + if(!file.atEnd()) { + qWarning() << "Import failed. Cause: read all but not EOF"; + return ""; + } + + file.close(); + + if(file.getZipError()!=UNZ_OK) { + qWarning() << "Import failed. Cause: file.close(): " << file.getZipError(); + return ""; } }