ReactOS 0.4.16-dev-91-g764881a
CZipCreatorImpl Struct Reference

Public Member Functions

unsigned JustDoIt ()
 

Public Attributes

CSimpleArray< CStringWm_items
 

Detailed Description

Definition at line 157 of file CZipCreator.cpp.

Member Function Documentation

◆ JustDoIt()

unsigned CZipCreatorImpl::JustDoIt ( )

Definition at line 221 of file CZipCreator.cpp.

222{
223 // TODO: Show progress.
224
225 if (m_items.GetSize() <= 0)
226 {
227 DPRINT1("GetSize() <= 0\n");
228 return CZCERR_ZEROITEMS;
229 }
230
232 for (INT iItem = 0; iItem < m_items.GetSize(); ++iItem)
233 {
234 DoAddFilesFromItem(files, m_items[iItem]);
235 }
236
237 if (files.GetSize() <= 0)
238 {
239 DPRINT1("files.GetSize() <= 0\n");
240
242 CStringW strText;
243 strText.Format(IDS_NOFILES, static_cast<PCWSTR>(m_items[0]));
244 MessageBoxW(NULL, strText, strTitle, MB_ICONERROR);
245
246 return CZCERR_NOFILES;
247 }
248
251
252 CStringW strZipName = DoGetZipName(m_items[0]);
253 zipFile zf = zipOpen2_64(strZipName, APPEND_STATUS_CREATE, NULL, &ffunc);
254 if (zf == 0)
255 {
256 DPRINT1("zf == 0\n");
257
258 int err = CZCERR_CREATE;
259
261 CStringW strText;
262 strText.Format(IDS_CANTCREATEZIP, static_cast<PCWSTR>(strZipName), err);
263 MessageBoxW(NULL, strText, strTitle, MB_ICONERROR);
264
265 return err;
266 }
267
268 // TODO: password
269 const char *password = NULL;
270 int zip64 = 1; // always zip64
271 zip_fileinfo zi;
272
273 int err = 0;
274 CStringW strTarget, strBaseName = DoGetBaseName(m_items[0]);
275 UINT nCodePage = GetZipCodePage(FALSE);
276 for (INT iFile = 0; iFile < files.GetSize(); ++iFile)
277 {
278 const CStringW& strFile = files[iFile];
279
281 if (!DoReadAllOfFile(strFile, contents, &zi))
282 {
283 DPRINT1("DoReadAllOfFile failed\n");
285 strTarget = strFile;
286 break;
287 }
288
289 unsigned long crc = 0;
290 if (password)
291 {
292 // TODO: crc = ...;
293 }
294
295 CStringA strNameInZip = DoGetNameInZip(strBaseName, strFile, nCodePage);
297 strNameInZip,
298 &zi,
299 NULL,
300 0,
301 NULL,
302 0,
303 NULL,
306 0,
307 -MAX_WBITS,
310 password,
311 crc,
313 (nCodePage == CP_UTF8 ? MINIZIP_UTF8_FLAG : 0),
314 zip64);
315 if (err)
316 {
317 DPRINT1("zipOpenNewFileInZip3_64\n");
318 break;
319 }
320
321 err = zipWriteInFileInZip(zf, contents.GetData(), contents.GetSize());
322 if (err)
323 {
324 DPRINT1("zipWriteInFileInZip\n");
325 break;
326 }
327
329 if (err)
330 {
331 DPRINT1("zipCloseFileInZip\n");
332 break;
333 }
334 }
335
336 zipClose(zf, NULL);
337
338 if (err)
339 {
340 DeleteFileW(strZipName);
341
343
344 CStringW strText;
345 if (err < 0)
346 strText.Format(IDS_CANTCREATEZIP, static_cast<PCWSTR>(strZipName), err);
347 else
348 strText.Format(IDS_CANTREADFILE, static_cast<PCWSTR>(strTarget));
349
350 MessageBoxW(NULL, strText, strTitle, MB_ICONERROR);
351 }
352 else
353 {
354 WCHAR szFullPath[MAX_PATH];
355 GetFullPathNameW(strZipName, _countof(szFullPath), szFullPath, NULL);
357 }
358
359 return err;
360}
static CStringW DoGetZipName(PCWSTR filename)
Definition: CZipCreator.cpp:15
@ CZCERR_NOFILES
@ CZCERR_ZEROITEMS
@ CZCERR_READ
@ CZCERR_CREATE
static CStringA DoGetNameInZip(const CStringW &basename, const CStringW &filename, UINT nCodePage)
Definition: CZipCreator.cpp:47
static void DoAddFilesFromItem(CSimpleArray< CStringW > &files, PCWSTR item)
static CStringW DoGetBaseName(PCWSTR filename)
Definition: CZipCreator.cpp:37
static BOOL DoReadAllOfFile(PCWSTR filename, CSimpleArray< BYTE > &contents, zip_fileinfo *pzi)
Definition: CZipCreator.cpp:65
#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:818
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
#define MINIZIP_COMPATIBLE_VERSION
Definition: precomp.h:41
UINT GetZipCodePage(BOOL bUnZip)
Definition: zipfldr.cpp:90
#define MINIZIP_UTF8_FLAG
Definition: precomp.h:43
#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
unsigned int UINT
Definition: ndis.h:50
#define err(...)
#define CP_UTF8
Definition: nls.h:20
#define SHCNE_CREATE
Definition: shlobj.h:1891
#define SHCNF_PATHW
Definition: shlobj.h:1925
#define _countof(array)
Definition: sndvol32.h:70
CSimpleArray< CStringW > m_items
const uint16_t * PCWSTR
Definition: typedefs.h:57
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:790
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
__wchar_t WCHAR
Definition: xmlstorage.h:180
int ZEXPORT zipClose(zipFile file, const char *global_comment)
Definition: zip.c:1883
int ZEXPORT zipOpenNewFileInZip4_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, uLong versionMadeBy, uLong flagBase, int zip64)
Definition: zip.c:1061
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 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 159 of file CZipCreator.cpp.

Referenced by JustDoIt().


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