JlCompress.h | JlCompress.h | |||
---|---|---|---|---|
skipping to change at line 12 | skipping to change at line 12 | |||
#define JLCOMPRESSFOLDER_H_ | #define JLCOMPRESSFOLDER_H_ | |||
#include "quazip.h" | #include "quazip.h" | |||
#include "quazipfile.h" | #include "quazipfile.h" | |||
#include "quazipfileinfo.h" | #include "quazipfileinfo.h" | |||
#include <QString> | #include <QString> | |||
#include <QDir> | #include <QDir> | |||
#include <QFileInfo> | #include <QFileInfo> | |||
#include <QFile> | #include <QFile> | |||
/// Utility class for typical operations. | ||||
/** | ||||
This class contains a number of useful static functions to perform | ||||
simple operations, such as mass ZIP packing or extraction. | ||||
*/ | ||||
class QUAZIP_EXPORT JlCompress { | class QUAZIP_EXPORT JlCompress { | |||
private: | private: | |||
/// Compress a single file. | ||||
/** | ||||
\param zip Opened zip to compress the file to. | ||||
\param fileName The full path to the source file. | ||||
\param fileDest The full name of the file inside the archive. | ||||
\return true if success, false otherwise. | ||||
*/ | ||||
static bool compressFile(QuaZip* zip, QString fileName, QString fileDes t); | static bool compressFile(QuaZip* zip, QString fileName, QString fileDes t); | |||
/// Compress a subdirectory. | ||||
/** | ||||
\param parentZip Opened zip containing the parent directory. | ||||
\param dir The full path to the directory to pack. | ||||
\param parentDir The full path to the directory corresponding to | ||||
the root of the ZIP. | ||||
\param recursive Whether to pack sub-directories as well or only | ||||
files. | ||||
\return true if success, false otherwise. | ||||
*/ | ||||
static bool compressSubDir(QuaZip* parentZip, QString dir, QString pare ntDir, bool recursive = true); | static bool compressSubDir(QuaZip* parentZip, QString dir, QString pare ntDir, bool recursive = true); | |||
/// Extract a single file. | ||||
/** | ||||
\param zip The opened zip archive to extract from. | ||||
\param fileName The full name of the file to extract. | ||||
\param fileDest The full path to the destination file. | ||||
\return true if success, false otherwise. | ||||
*/ | ||||
static bool extractFile(QuaZip* zip, QString fileName, QString fileDest ); | static bool extractFile(QuaZip* zip, QString fileName, QString fileDest ); | |||
/// Remove some files. | ||||
/** | ||||
\param listFile The list of files to remove. | ||||
\return true if success, false otherwise. | ||||
*/ | ||||
static bool removeFile(QStringList listFile); | static bool removeFile(QStringList listFile); | |||
public: | public: | |||
/// Compress a single file. | ||||
/** | ||||
\param fileCompressed The name of the archive. | ||||
\param file The file to compress. | ||||
\return true if success, false otherwise. | ||||
*/ | ||||
static bool compressFile(QString fileCompressed, QString file); | static bool compressFile(QString fileCompressed, QString file); | |||
/// Compress a list of files. | ||||
/** | ||||
\param fileCompressed The name of the archive. | ||||
\param files The file list to compress. | ||||
\return true if success, false otherwise. | ||||
*/ | ||||
static bool compressFiles(QString fileCompressed, QStringList files); | static bool compressFiles(QString fileCompressed, QStringList files); | |||
/// Compress a whole directory. | ||||
/** | ||||
\param fileCompressed The name of the archive. | ||||
\param dir The directory to compress. | ||||
\param recursive Whether to pack the subdirectories as well, or | ||||
just regular files. | ||||
\return true if success, false otherwise. | ||||
*/ | ||||
static bool compressDir(QString fileCompressed, QString dir = QString() , bool recursive = true); | static bool compressDir(QString fileCompressed, QString dir = QString() , bool recursive = true); | |||
public: | public: | |||
static QString extractFile(QString fileCompressed, QString file, QStrin | /// Extract a single file. | |||
g fileDest = QString()); | /** | |||
\param fileCompressed The name of the archive. | ||||
\param fileName The file to extract. | ||||
\param fileDest The destination file, assumed to be identical to | ||||
\a file if left empty. | ||||
\return The list of the full paths of the files extracted, empty on f | ||||
ailure. | ||||
*/ | ||||
static QString extractFile(QString fileCompressed, QString fileName, QS | ||||
tring fileDest = QString()); | ||||
/// Extract a list of files. | ||||
/** | ||||
\param fileCompressed The name of the archive. | ||||
\param files The file list to extract. | ||||
\param dir The directory to put the files to, the current | ||||
directory if left empty. | ||||
\return The list of the full paths of the files extracted, empty on f | ||||
ailure. | ||||
*/ | ||||
static QStringList extractFiles(QString fileCompressed, QStringList fil es, QString dir = QString()); | static QStringList extractFiles(QString fileCompressed, QStringList fil es, QString dir = QString()); | |||
/// Extract a whole archive. | ||||
/** | ||||
\param fileCompressed The name of the archive. | ||||
\param dir The directory to extract to, the current directory if | ||||
left empty. | ||||
\return The list of the full paths of the files extracted, empty on f | ||||
ailure. | ||||
*/ | ||||
static QStringList extractDir(QString fileCompressed, QString dir = QSt ring()); | static QStringList extractDir(QString fileCompressed, QString dir = QSt ring()); | |||
/// Get the file list. | ||||
/** | ||||
\return The list of the files in the archive, or, more precisely, the | ||||
list of the entries, including both files and directories if they | ||||
are present separately. | ||||
*/ | ||||
static QStringList getFileList(QString fileCompressed); | static QStringList getFileList(QString fileCompressed); | |||
}; | }; | |||
#endif /* JLCOMPRESSFOLDER_H_ */ | #endif /* JLCOMPRESSFOLDER_H_ */ | |||
End of changes. 11 change blocks. | ||||
3 lines changed or deleted | 88 lines changed or added | |||