-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fmk - Compressing Template dir and changing python script name to par…
…seDAKOTA and pointing at new agave app: many resulting changes
- Loading branch information
Showing
12 changed files
with
2,008 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
|
||
INCLUDEPATH += $$PWD | ||
|
||
win32{ | ||
INCLUDEPATH += $$[QT_INSTALL_HEADERS]/QtZlib | ||
} | ||
|
||
HEADERS += $$PWD/zip.h $$PWD/ioapi.h | ||
|
||
SOURCES += $$PWD/zip.c $$PWD/ioapi.c $$PWD/*.cpp | ||
|
||
linux{ | ||
LIBS += -lz | ||
} | ||
|
||
macx{ | ||
LIBS += -lz | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
#include <ZipUtils.h> | ||
#include <zip.h> | ||
#include <QDirIterator> | ||
|
||
bool ZipUtils::ZipFolder(QDir directoryToZip, QString zipFilePath) | ||
{ | ||
|
||
zipFile newZipFile = zipOpen(zipFilePath.toStdString().c_str(), APPEND_STATUS_CREATE); | ||
|
||
//Checking if the file is opened | ||
if(NULL == newZipFile) | ||
return false; | ||
|
||
int result = ZIP_OK; | ||
|
||
QDirIterator dirIt(directoryToZip, QDirIterator::Subdirectories); | ||
|
||
//We need to find the parent to get relative path including directory name | ||
QDir parentDir(directoryToZip.absolutePath()); | ||
parentDir.cdUp(); | ||
|
||
//Looping through files and directories | ||
while (dirIt.hasNext()) | ||
{ | ||
QFileInfo fileInfo(dirIt.next()); | ||
|
||
if(fileInfo.isDir()) | ||
continue; | ||
|
||
if(fileInfo.fileName() == "." || fileInfo.fileName() == "..") | ||
continue; | ||
|
||
QFile afile(fileInfo.filePath()); | ||
|
||
|
||
if(afile.exists()) | ||
{ | ||
|
||
if(!afile.open(QFile::ReadOnly)) | ||
return false; | ||
|
||
QByteArray fileByteArray = afile.readAll(); | ||
|
||
QString relFilePath = parentDir.relativeFilePath(fileInfo.absoluteFilePath()); | ||
|
||
result = zipOpenNewFileInZip(newZipFile, | ||
relFilePath.toStdString().c_str(), | ||
NULL, | ||
NULL, | ||
0, | ||
NULL, | ||
0, | ||
NULL, | ||
Z_DEFLATED, | ||
Z_BEST_COMPRESSION); | ||
|
||
//checking if file entry is opened | ||
if(result != ZIP_OK) | ||
return false; | ||
|
||
result = zipWriteInFileInZip(newZipFile, fileByteArray.data(), fileByteArray.length()); | ||
|
||
//checking if writing was successful | ||
if(result != ZIP_OK) | ||
return false; | ||
|
||
//close file inside zip | ||
result = zipCloseFileInZip(newZipFile); | ||
|
||
//checking if file entry closing was successful | ||
if(result != ZIP_OK) | ||
return false; | ||
} | ||
|
||
} | ||
|
||
|
||
|
||
//Closing zip file | ||
result = zipClose(newZipFile, "Compressed directory"); | ||
|
||
return result; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#ifndef ZIPUTILS_H | ||
#define ZIPUTILS_H | ||
#include <QDir> | ||
#include <QString> | ||
|
||
namespace ZipUtils { | ||
|
||
bool ZipFolder(QDir directoryToZip, QString zipFilePath); | ||
|
||
} | ||
#endif // ZIPUTILS_H |
Oops, something went wrong.