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
00033
00034 #ifndef ZipFileH
00035 #define ZipFileH
00036
00037
00038 #include <zeusbase/Config/PlatformDefines.hpp>
00039 #include <zeusbase/System/File.h>
00040 #include <zeusbase/System/StringList.h>
00041
00042 BEGIN_NAMESPACE_Zeus
00043
00044 class TZipDataSource;
00045 class TZippedFileEntry;
00046
00047
00051
00052 zeusbase_class TZipFile : public TFile
00053 {
00054 public:
00055 TZipFile(const TString& rFileName);
00056
00057
00058 Retval addFileEntry(const IString& rEntryName, const IString& rFileName, bool bOverwriteIfExists, Int iZipLevel = 4);
00059 Retval deleteFileEntry(Int iIndex);
00060 Retval getFileEntry(Int iIndex, TZippedFileEntry*& rpEntry) const;
00061 Retval getFileEntryByName(const IString& rEntryName, TZippedFileEntry*& rpEntry) const;
00062 Int getFileEntryCount() const;
00063 bool isValid() const;
00064 Retval removeFileEntry(const IString& rEntryName);
00065
00066
00067 void createArchive();
00068 Retval saveArchive();
00069 void setPassword(const IString& rPassword);
00070 Retval unzipAllFiles(const IString& rTargetDirectory,
00071 bool bOptUsePath = true,
00072 bool bOptOverwrite = false);
00073 Retval unzipFiles(const IString& rTargetDirectory,
00074 const IStringList& lstEntries,
00075 bool bOptUsePath = true,
00076 bool bOptOverwrite = false);
00077 Retval unzipSingleFile(const IString& rTargetDirectory,
00078 const IString& rFileEntry,
00079 bool bOptUsePath = true,
00080 bool bOptOverwrite = false);
00081
00082 protected:
00083 virtual ~TZipFile();
00084
00085 void checkOpen() const;
00086 void close();
00087
00088 private:
00090 mutable TZipDataSource* m_pDataSource;
00092 TString m_strPassword;
00093 };
00094
00095
00096
00097
00100
00101 inline void TZipFile::setPassword(const IString& rPassword)
00102 {
00103 m_strPassword = rPassword;
00104 }
00105
00106
00109
00110 inline Retval TZipFile::unzipSingleFile(const IString& rTargetDirectory,
00111 const IString& rFileEntry,
00112 bool bOptUsePath ,
00113 bool bOptOverwrite )
00114 {
00115 TStringList lstFiles;
00116 lstFiles.add(rFileEntry);
00117 return unzipFiles(rTargetDirectory, lstFiles, bOptUsePath, bOptOverwrite);
00118 }
00119
00120
00121 END_NAMESPACE_Zeus
00122
00123 #endif