160 {
161 zr=GetZipItem(hz,i,&ze);
162 zr=UnzipItem(hz,i,ze.name);
163
164 if(zr != ZR_OK)
165 {
166 //获取Zip文件内容失败
167 CloseZip(hz);
168 return FALSE;
169 }
170 }
171
172 CloseZip(hz);
173 return TRUE;
174}
175
176/////////////////////////////////////////////////////////////////////////////
177// 函数说明: 检查指定的文件夹是否存在
178// 参数说明: [in]:strPath 检查的文件夹 (此方法会主动向路径末尾添加*.*)
179// 返回值:BOOL类型,存在返回TRUE,否则为FALSE
180// 函数作者:
181// 创建日期: 2009-09-27 下午 02:16:36
182/////////////////////////////////////////////////////////////////////////////
183BOOL CZipImplement::FolderExist(CString& strPath)
184{
185 CString sCheckPath = strPath;
186
187 if(sCheckPath.Right(1) != L"\\")
188 sCheckPath += L"\\";
189
190 sCheckPath += L"*.*";
191
192 WIN32_FIND_DATA wfd;
193 BOOL rValue = FALSE;
194
195 HANDLE hFind = FindFirstFile(sCheckPath, &wfd);
196
197 if ((hFind!=INVALID_HANDLE_VALUE) &&
198 (wfd.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY) || (wfd.dwFileAttributes&FILE_ATTRIBUTE_ARCHIVE))
199 {
200 //如果存在并类型是文件夹
201 rValue = TRUE;
202 }
203
204 FindClose(hFind);
205 return rValue;
206}
207
208/////////////////////////////////////////////////////////////////////////////
209// 函数说明: 遍历文件夹
210// 参数说明: [in]:strFile 遍历的文件夹(此方法会主动向路径末尾添加*.*)
211// 返回值:BOOL类型,存在返回TRUE,否则为FALSE
212// 函数作者:
213// 创建日期: 2009-09-27 下午 02:16:36
214/////////////////////////////////////////////////////////////////////////////
215void CZipImplement::BrowseFile(CString &strFile)
216{
217 CFileFind ff;
218 CString szDir = strFile;
219
220 if(szDir.Right(1) != L"\\")
221 szDir += L"\\";
222
223 szDir += L"*.*";
224
225 BOOL res = ff.FindFile(szDir);
226 while(res)
227 {
228 res = ff.FindNextFile();
229 if(ff.IsDirectory() && !ff.IsDots())
230 {
231 //如果是一个子目录,用递归继续往深一层找
232 CString strPath = ff.GetFilePath();
233
234 CString subPath;
235 GetRelativePath(strPath,subPath);
236 //将文件添加到ZIP文件
237 ZipAddFolder(hz,subPath);
238 BrowseFile(strPath);
239 }
240 else if(!ff.IsDirectory() && !ff.IsDots())
241 {
242 //显示当前访问的文件(完整路径)
243 CString strPath = ff.GetFilePath();
244 CString subPath;
245
246 GetRelativePath(strPath,subPath);
247 //将文件添加到ZIP文件
248 ZipAdd(hz,subPath,strPath);
249 }
250 }
251
252 //关闭
253 ff.Close();
254}
255
256/////////////////////////////////////////////////////////////////////////////
257// 函