00001 /* 00002 Free Download Manager Copyright (c) 2003-2007 FreeDownloadManager.ORG 00003 Open Download Manager Copyright (c) 2008-2010 OpenDownloadManager.ORG 00004 */ 00005 00006 #if !defined(AFX_FSZIPARCHIVEREBUILDER_H__223E1FEF_5709_4CAD_A80F_FE09EFF660B4__INCLUDED_) 00007 #define AFX_FSZIPARCHIVEREBUILDER_H__223E1FEF_5709_4CAD_A80F_FE09EFF660B4__INCLUDED_ 00008 00009 #if _MSC_VER > 1000 00010 #pragma once 00011 #endif 00012 00013 #include "fsArchiveRebuilder.h" 00014 #include <fsString.h> 00015 00016 namespace fsArchive 00017 { 00018 00019 const UINT32 ZIP_LOCALFILEHEADER_SIG = 0x04034b50; 00020 const UINT32 ZIP_FILEHEADER_SIG = 0x02014b50; 00021 const UINT32 ZIP_ENDOFCENTRALDIR_SIG = 0x06054b50; 00022 const UINT32 ZIP_SPLIT_SIG = 0x08074b50; 00023 const UINT32 ZIP_TEMPSPANNINGMARKER_SIG = 0x30304b50; 00024 00025 const UINT32 ZIP_SFXMAXSIZE = 150*1024; 00026 const UINT32 ZIP_BEGIN_SIG = ZIP_LOCALFILEHEADER_SIG; 00027 00028 #pragma pack (push) 00029 #pragma pack (1) 00030 00031 struct fsZipLocalFileHeader 00032 { 00033 WORD wExtractVersion; 00034 WORD wGenFlags; 00035 WORD wCompMethod; 00036 WORD wLastModTime; 00037 WORD wLastModDate; 00038 UINT32 uCRC; 00039 UINT32 uSizeComp; 00040 UINT32 uSizeUncomp; 00041 WORD wFileNameLen; 00042 WORD wExtraLen; 00043 }; 00044 00045 struct fsZipDataDescriptor 00046 { 00047 UINT32 uCRC; 00048 UINT32 uSizeComp; 00049 UINT32 uSizeUncomp; 00050 }; 00051 00052 struct fsZipFileHeader 00053 { 00054 WORD wVerMadeBy; 00055 WORD wExtractVer; 00056 WORD wGenFlags; 00057 WORD wCompMethod; 00058 WORD wLastModTime; 00059 WORD wLastModDate; 00060 UINT32 uCRC; 00061 UINT32 uSizeComp; 00062 UINT32 uSizeUncomp; 00063 WORD wFileNameLen; 00064 WORD wExtraLen; 00065 WORD wFileCommentLen; 00066 WORD wDiskNumberStart; 00067 WORD wIntFileAttribs; 00068 UINT32 uExtFileAttribs; 00069 UINT32 uLocHdrRelOffset; 00070 }; 00071 00072 struct fsZipEndOfCentralDirHdr 00073 { 00074 WORD wDiskNumber; 00075 WORD wDiskNumberWithCDirStart; 00076 WORD wcCDirEntries; 00077 WORD wcFilesTotal; 00078 UINT32 uCDirSize; 00079 UINT32 uStartCDirOffsetWithRespectToStartingDiskNumber; 00080 WORD wZipCommentLen; 00081 }; 00082 00083 enum fsZipArchiveRebuilderResult 00084 { 00085 ZARR_NONSEEKABLEZIP = ARR_APPRES 00086 }; 00087 00088 struct fsZipLocalFile 00089 { 00090 fsZipLocalFileHeader hdr; 00091 fsString strFileName; 00092 LPBYTE pbExtraInfo; 00093 fsZipDataDescriptor descriptor; 00094 UINT32 sigAfter; 00095 fsArchiveFilePosition position; 00096 00097 fsZipLocalFile () {} 00098 00099 fsZipLocalFile (fsZipLocalFile& file) 00100 { 00101 operator= (file); 00102 } 00103 00104 fsZipLocalFile& operator= (fsZipLocalFile& file) 00105 { 00106 hdr = file.hdr; 00107 strFileName = file.strFileName; 00108 pbExtraInfo = file.pbExtraInfo; 00109 descriptor = file.descriptor; 00110 sigAfter = file.sigAfter; 00111 position = file.position; 00112 return *this; 00113 } 00114 }; 00115 00116 struct fsZipFile 00117 { 00118 fsZipFileHeader hdr; 00119 fsString strFileName; 00120 LPBYTE pbExtraInfo; 00121 fsString strComment; 00122 00123 fsZipFile () {} 00124 00125 fsZipFile (fsZipFile& file) 00126 { 00127 operator= (file); 00128 } 00129 00130 fsZipFile& operator= (fsZipFile& file) 00131 { 00132 hdr = file.hdr; 00133 strFileName = file.strFileName; 00134 pbExtraInfo = file.pbExtraInfo; 00135 strComment = file.strComment; 00136 return *this; 00137 } 00138 }; 00139 00140 #include "list.h" 00141 00142 class fsZipArchiveRebuilder : public fsArchiveRebuilder 00143 { 00144 public: 00145 00146 const fsArchiveFilePosition* GetFilePosition (int iFile); 00147 virtual fsString GetFileName (int iFile); 00148 virtual int GetFileCount(); 00149 virtual BOOL RebuildArchive (fs::list <fsString> vFileNames); 00150 fsZipArchiveRebuilder(); 00151 virtual ~fsZipArchiveRebuilder(); 00152 00153 protected: 00154 00155 DWORD SaveEndOfCDirRecord(); 00156 DWORD SaveFilesHeaders(); 00157 DWORD SaveLocalFilesHeaders(); 00158 00159 virtual DWORD SaveArchiveHeaders_imp(); 00160 00161 int FindFile (LPCSTR pszFile, int iProbIndex = -1); 00162 00163 void Free(); 00164 00165 void CorrectCDir(); 00166 00167 void RemoveFile (int iIndex); 00168 00169 virtual DWORD RetreiveArchiveContent(); 00170 fs::list <fsZipLocalFile> m_vLocalFiles; 00171 fs::list <fsZipFile> m_vFiles; 00172 fsZipEndOfCentralDirHdr m_hdrEndOfCDir; 00173 fsString m_strZipComment; 00174 }; 00175 00176 #pragma pack (pop) 00177 00178 }; 00179 00180 #endif
1.5.6