00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef OSDAB_ZIP__H
00029 #define OSDAB_ZIP__H
00030
00031 #include <QtGlobal>
00032 #include <QMap>
00033
00034 #include <zlib.h>
00035
00036 class ZipPrivate;
00037
00038 class QIODevice;
00039 class QFile;
00040 class QDir;
00041 class QStringList;
00042 class QString;
00043
00044
00045 class Zip
00046 {
00047 public:
00048 enum ErrorCode
00049 {
00050 Ok,
00051 ZlibInit,
00052 ZlibError,
00053 FileExists,
00054 OpenFailed,
00055 NoOpenArchive,
00056 FileNotFound,
00057 ReadFailed,
00058 WriteFailed,
00059 SeekFailed
00060 };
00061
00062 enum CompressionLevel
00063 {
00064 Store,
00065 Deflate1 = 1, Deflate2, Deflate3, Deflate4,
00066 Deflate5, Deflate6, Deflate7, Deflate8, Deflate9,
00067 AutoCPU, AutoMIME, AutoFull
00068 };
00069
00070 enum CompressionOption
00071 {
00073 RelativePaths = 0x0001,
00075 AbsolutePaths = 0x0002,
00077 IgnorePaths = 0x0004
00078 };
00079 Q_DECLARE_FLAGS(CompressionOptions, CompressionOption)
00080
00081 Zip();
00082 virtual ~Zip();
00083
00084 bool isOpen() const;
00085
00086 void setPassword(const QString& pwd);
00087 void clearPassword();
00088 QString password() const;
00089
00090 ErrorCode createArchive(const QString& file, bool overwrite = true);
00091 ErrorCode createArchive(QIODevice* device);
00092
00093 QString archiveComment() const;
00094 void setArchiveComment(const QString& comment);
00095
00096 ErrorCode addDirectoryContents(const QString& path, CompressionLevel level = AutoFull);
00097 ErrorCode addDirectoryContents(const QString& path, const QString& root, CompressionLevel level = AutoFull);
00098
00099 ErrorCode addDirectory(const QString& path, CompressionOptions options = RelativePaths, CompressionLevel level = AutoFull);
00100 ErrorCode addDirectory(const QString& path, const QString& root, CompressionLevel level = AutoFull);
00101 ErrorCode addDirectory(const QString& path, const QString& root, CompressionOptions options = RelativePaths, CompressionLevel level = AutoFull);
00102
00103 ErrorCode closeArchive();
00104
00105 QString formatError(ErrorCode c) const;
00106
00107 private:
00108 ZipPrivate* d;
00109 };
00110
00111 Q_DECLARE_OPERATORS_FOR_FLAGS(Zip::CompressionOptions)
00112
00113 #endif // OSDAB_ZIP__H