Go to the documentation of this file.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
00029
00030
00031
00032 #ifndef ZipFileH
00033 #define ZipFileH
00034
00035 #include <zeusbase/Config/PlatformDefines.hpp>
00036 #include <zeusbase/System/File.h>
00037 #include <zeusbase/System/Directory.h>
00038 #include <zeusbase/System/StringList.h>
00039
00040 BEGIN_NAMESPACE_Zeus
00041
00042 class TZipDataSource;
00043 class TZippedFileEntry;
00044
00045
00049
00050 zeusbase_class TZipFile : public TFile
00051 {
00052 public:
00053 TZipFile(const TString& rFileName);
00054
00055
00056 Retval addFileEntry(const IString& rEntryName, const IString& rFileName, bool bOverwriteIfExists, Int iZipLevel = 4);
00057 Retval deleteFileEntry(Int iIndex);
00058 Retval getFileEntry(Int iIndex, TZippedFileEntry*& rpEntry) const;
00059 Retval getFileEntryByName(const IString& rEntryName, TZippedFileEntry*& rpEntry) const;
00060 Int getFileEntryCount() const;
00061 bool isValid() const;
00062 Retval removeFileEntry(const IString& rEntryName);
00063
00064
00065 void createArchive();
00066 Retval saveArchive();
00067 void setPassword(const IString& rPassword);
00068 Retval unzipAllFiles(const IString& rTargetDirectory,
00069 bool bOptUsePath = true,
00070 bool bOptOverwrite = false);
00071 Retval unzipFiles(const IString& rTargetDirectory,
00072 const IStringList& lstEntries,
00073 bool bOptUsePath = true,
00074 bool bOptOverwrite = false);
00075 Retval unzipSingleFile(const IString& rTargetDirectory,
00076 const IString& rFileEntry,
00077 bool bOptUsePath = true,
00078 bool bOptOverwrite = false);
00079
00080 Retval zipFiles(const IString& rSourceDirectory,
00081 bool bRecursive,
00082 bool bOverwriteIfExists,
00083 Int iZipLevel = 4);
00084
00085 Retval zipFiles(const IString& rSourceDirectory,
00086 const IString& rFileFilter,
00087 bool bRecursive,
00088 bool bOverwriteIfExists,
00089 Int iZipLevel = 4);
00090
00091 protected:
00092 virtual ~TZipFile();
00093
00094 void checkOpen() const;
00095 void close();
00096
00097 private:
00099 mutable TZipDataSource* m_pDataSource;
00101 TString m_strPassword;
00102
00103 Retval zipFiles_internal(const IList<TDirectoryItem>& rList,
00104 const TString& rEntryBaseName,
00105 bool bRecursive,
00106 bool bOverwriteIfExists,
00107 Int iZipLevel);
00108 };
00109
00110
00111
00112
00115
00116 inline void TZipFile::setPassword(const IString& rPassword)
00117 {
00118 m_strPassword = rPassword;
00119 }
00120
00121
00124
00125 inline Retval TZipFile::unzipSingleFile(const IString& rTargetDirectory,
00126 const IString& rFileEntry,
00127 bool bOptUsePath ,
00128 bool bOptOverwrite )
00129 {
00130 TStringList lstFiles;
00131 lstFiles.add(rFileEntry);
00132 return unzipFiles(rTargetDirectory, lstFiles, bOptUsePath, bOptOverwrite);
00133 }
00134
00135
00136
00147
00148 inline Retval TZipFile::zipFiles(const IString& rSourceDirectory,
00149 bool bRecursive,
00150 bool bOverwriteIfExists,
00151 Int iZipLevel )
00152 {
00153 return zipFiles(rSourceDirectory, TString(L"*.*"), bRecursive,
00154 bOverwriteIfExists, iZipLevel);
00155 }
00156
00157
00158 END_NAMESPACE_Zeus
00159
00160 #endif