ReactOS 0.4.15-dev-7998-gdb93cb1
zippidl.cpp
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS Zip Shell Extension
3 * LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
4 * PURPOSE: zip pidl handling
5 * COPYRIGHT: Copyright 2017-2019 Mark Jansen (mark.jansen@reactos.org)
6 * Copyright 2023 Katayama Hirofumi MZ (katayama.hirofumi.mz@gmail.com)
7 */
8
9#include "precomp.h"
10
12{
13 size_t cbData = sizeof(ZipPidlEntry) + wcslen(lpString) * sizeof(WCHAR);
14 if (cbData > MAXWORD)
15 return NULL;
16
17 ZipPidlEntry* pidl = (ZipPidlEntry*)SHAlloc(cbData + sizeof(WORD));
18 if (!pidl)
19 return NULL;
20
21 ZeroMemory(pidl, cbData + sizeof(WORD));
22
23 pidl->cb = (WORD)cbData;
24 pidl->MagicType = 'z';
25 pidl->ZipType = Type;
26
28 {
29 pidl->CompressedSize = info.compressed_size;
30 pidl->UncompressedSize = info.uncompressed_size;
31 pidl->DosDate = info.dosDate;
32 pidl->Password = info.flag & MINIZIP_PASSWORD_FLAG;
33 }
34
35 wcscpy(pidl->Name, lpString);
36 *(WORD*)((char*)pidl + cbData) = 0; // The end of an ITEMIDLIST
37
38 return (LPITEMIDLIST)pidl;
39}
40
42{
43 const ZipPidlEntry* zipPidl = (const ZipPidlEntry*)pidl;
44 if (zipPidl->MagicType == 'z')
45 return zipPidl;
46 return NULL;
47}
Type
Definition: Type.h:7
#define NULL
Definition: types.h:112
#define MINIZIP_PASSWORD_FLAG
Definition: precomp.h:42
LPVOID WINAPI SHAlloc(SIZE_T len)
Definition: shellole.c:304
unsigned short WORD
Definition: ntddk_ex.h:93
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define MAXWORD
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
ITEMIDLIST UNALIGNED * LPITEMIDLIST
Definition: shtypes.idl:41
const ITEMIDLIST UNALIGNED * LPCITEMIDLIST
Definition: shtypes.idl:42
WCHAR Name[1]
Definition: zippidl.hpp:28
ULONG64 UncompressedSize
Definition: zippidl.hpp:25
BOOLEAN Password
Definition: zippidl.hpp:21
ZipPidlType ZipType
Definition: zippidl.hpp:22
ULONG DosDate
Definition: zippidl.hpp:26
ULONG64 CompressedSize
Definition: zippidl.hpp:24
BYTE MagicType
Definition: zippidl.hpp:20
const uint16_t * PCWSTR
Definition: typedefs.h:57
#define ZeroMemory
Definition: winbase.h:1712
__wchar_t WCHAR
Definition: xmlstorage.h:180
const ZipPidlEntry * _ZipFromIL(LPCITEMIDLIST pidl)
Definition: zippidl.cpp:41
LPITEMIDLIST _ILCreate(ZipPidlType Type, PCWSTR lpString, unz_file_info64 &info)
Definition: zippidl.cpp:11
ZipPidlType
Definition: zippidl.hpp:11
@ ZIP_PIDL_DIRECTORY
Definition: zippidl.hpp:12