ReactOS 0.4.15-dev-5666-gc548b97
CZipCreatorImpl Struct Reference

Public Member Functions

unsigned JustDoIt ()
 

Public Attributes

CSimpleArray< CStringWm_items
 

Detailed Description

Definition at line 164 of file CZipCreator.cpp.

Member Function Documentation

◆ JustDoIt()

unsigned CZipCreatorImpl::JustDoIt ( )

Definition at line 228 of file CZipCreator.cpp.

229{
230 // TODO: Show progress.
231
232 if (m_items.GetSize() <= 0)
233 {
234 DPRINT1("GetSize() <= 0\n");
235 return CZCERR_ZEROITEMS;
236 }
237
239 for (INT iItem = 0; iItem < m_items.GetSize(); ++iItem)
240 {
241 DoAddFilesFromItem(files, m_items[iItem]);
242 }
243
244 if (files.GetSize() <= 0)
245 {
246 DPRINT1("files.GetSize() <= 0\n");
247
249 CStringW strText;
250 strText.Format(IDS_NOFILES, static_cast<LPCWSTR>(m_items[0]));
251 MessageBoxW(NULL, strText, strTitle, MB_ICONERROR);
252
253 return CZCERR_NOFILES;
254 }
255
258
259 CStringW strZipName = DoGetZipName(m_items[0]);
260 zipFile zf = zipOpen2_64(strZipName, APPEND_STATUS_CREATE, NULL, &ffunc);
261 if (zf == 0)
262 {
263 DPRINT1("zf == 0\n");
264
265 int err = CZCERR_CREATE;
266
268 CStringW strText;
269 strText.Format(IDS_CANTCREATEZIP, static_cast<LPCWSTR>(strZipName), err);
270 MessageBoxW(NULL, strText, strTitle, MB_ICONERROR);
271
272 return err;
273 }
274
275 // TODO: password
276 const char *password = NULL;
277 int zip64 = 1; // always zip64
278 zip_fileinfo zi;
279
280 int err = 0;
281 CStringW strTarget, strBaseName = DoGetBaseName(m_items[0]);
282 for (INT iFile = 0; iFile < files.GetSize(); ++iFile)
283 {
284 const CStringW& strFile = files[iFile];
285
287 if (!DoReadAllOfFile(strFile, contents, &zi))
288 {
289 DPRINT1("DoReadAllOfFile failed\n");
291 strTarget = strFile;
292 break;
293 }
294
295 unsigned long crc = 0;
296 if (password)
297 {
298 // TODO: crc = ...;
299 }
300
301 CStringA strNameInZip = DoGetNameInZip(strBaseName, strFile);
303 strNameInZip,
304 &zi,
305 NULL,
306 0,
307 NULL,
308 0,
309 NULL,
312 0,
313 -MAX_WBITS,
316 password,
317 crc,
318 zip64);
319 if (err)
320 {
321 DPRINT1("zipOpenNewFileInZip3_64\n");
322 break;
323 }
324
325 err = zipWriteInFileInZip(zf, contents.GetData(), contents.GetSize());
326 if (err)
327 {
328 DPRINT1("zipWriteInFileInZip\n");
329 break;
330 }
331
333 if (err)
334 {
335 DPRINT1("zipCloseFileInZip\n");
336 break;
337 }
338 }
339
340 zipClose(zf, NULL);
341
342 if (err)
343 {
344 DeleteFileW(strZipName);
345
347
348 CStringW strText;
349 if (err < 0)
350 strText.Format(IDS_CANTCREATEZIP, static_cast<LPCWSTR>(strZipName), err);
351 else
352 strText.Format(IDS_CANTREADFILE, static_cast<LPCWSTR>(strTarget));
353
354 MessageBoxW(NULL, strText, strTitle, MB_ICONERROR);
355 }
356 else
357 {
358 WCHAR szFullPath[MAX_PATH];
359 GetFullPathNameW(strZipName, _countof(szFullPath), szFullPath, NULL);
361 }
362
363 return err;
364}
@ CZCERR_NOFILES
@ CZCERR_ZEROITEMS
@ CZCERR_READ
@ CZCERR_CREATE
static CStringW DoGetBaseName(LPCWSTR filename)
Definition: CZipCreator.cpp:44
static void DoAddFilesFromItem(CSimpleArray< CStringW > &files, LPCWSTR item)
static BOOL DoReadAllOfFile(LPCWSTR filename, CSimpleArray< BYTE > &contents, zip_fileinfo *pzi)
Definition: CZipCreator.cpp:72
static CStringW DoGetZipName(LPCWSTR filename)
Definition: CZipCreator.cpp:15
static CStringA DoGetNameInZip(const CStringW &basename, const CStringW &filename)
Definition: CZipCreator.cpp:54
#define DPRINT1
Definition: precomp.h:8
EXTERN_C void WINAPI SHChangeNotify(LONG wEventId, UINT uFlags, LPCVOID dwItem1, LPCVOID dwItem2)
void __cdecl Format(UINT nFormatID,...)
Definition: cstringt.h:753
#define NULL
Definition: types.h:112
#define IDS_CANTCREATEZIP
Definition: resource.h:50
#define IDS_ERRORTITLE
Definition: resource.h:47
#define IDS_CANTREADFILE
Definition: resource.h:51
#define IDS_NOFILES
Definition: resource.h:49
#define MAX_PATH
Definition: compat.h:34
#define Z_DEFLATED
Definition: zlib.h:146
#define Z_DEFAULT_STRATEGY
Definition: zlib.h:137
#define MAX_WBITS
Definition: zlib.h:151
#define Z_DEFAULT_COMPRESSION
Definition: zlib.h:130
BOOL WINAPI DeleteFileW(IN LPCWSTR lpFileName)
Definition: delete.c:39
DWORD WINAPI GetFullPathNameW(IN LPCWSTR lpFileName, IN DWORD nBufferLength, OUT LPWSTR lpBuffer, OUT LPWSTR *lpFilePart)
Definition: path.c:1106
#define DEF_MEM_LEVEL
Definition: zutil.h:53
void fill_win32_filefunc64W(zlib_filefunc64_def *pzlib_filefunc_def)
Definition: iowin32.c:457
static const char * contents
Definition: parser.c:511
static WCHAR password[]
Definition: url.c:33
#define err(...)
#define SHCNE_CREATE
Definition: shlobj.h:1743
#define SHCNF_PATHW
Definition: shlobj.h:1777
#define _countof(array)
Definition: sndvol32.h:68
CSimpleArray< CStringW > m_items
int32_t INT
Definition: typedefs.h:58
_In_ ULONG_PTR iFile
Definition: winddi.h:3835
int WINAPI MessageBoxW(_In_opt_ HWND hWnd, _In_opt_ LPCWSTR lpText, _In_opt_ LPCWSTR lpCaption, _In_ UINT uType)
#define MB_ICONERROR
Definition: winuser.h:781
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
__wchar_t WCHAR
Definition: xmlstorage.h:180
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
int ZEXPORT zipClose(zipFile file, const char *global_comment)
Definition: zip.c:1883
zipFile ZEXPORT zipOpen2_64(const void *pathname, int append, zipcharpc *globalcomment, zlib_filefunc64_def *pzlib_filefunc_def)
Definition: zip.c:938
int ZEXPORT zipWriteInFileInZip(zipFile file, const void *buf, unsigned int len)
Definition: zip.c:1408
int ZEXPORT zipOpenNewFileInZip3_64(zipFile file, const char *filename, const zip_fileinfo *zipfi, const void *extrafield_local, uInt size_extrafield_local, const void *extrafield_global, uInt size_extrafield_global, const char *comment, int method, int level, int raw, int windowBits, int memLevel, int strategy, const char *password, uLong crcForCrypting, int zip64)
Definition: zip.c:1302
int ZEXPORT zipCloseFileInZip(zipFile file)
Definition: zip.c:1751
#define APPEND_STATUS_CREATE
Definition: zip.h:112
voidp zipFile
Definition: zip.h:69

Member Data Documentation

◆ m_items

CSimpleArray<CStringW> CZipCreatorImpl::m_items

Definition at line 166 of file CZipCreator.cpp.

Referenced by JustDoIt().


The documentation for this struct was generated from the following file: