2017-12-29 22:45:02 +00:00
|
|
|
/*
|
|
|
|
* PROJECT: ReactOS Zip Shell Extension
|
|
|
|
* LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
|
|
|
|
* PURPOSE: zip pidl handling
|
2019-02-27 21:18:52 +00:00
|
|
|
* COPYRIGHT: Copyright 2017-2019 Mark Jansen (mark.jansen@reactos.org)
|
2023-07-17 11:12:45 +00:00
|
|
|
* Copyright 2023 Katayama Hirofumi MZ (katayama.hirofumi.mz@gmail.com)
|
2017-12-29 22:45:02 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "precomp.h"
|
|
|
|
|
2023-07-17 11:12:45 +00:00
|
|
|
LPITEMIDLIST _ILCreate(ZipPidlType Type, PCWSTR lpString, unz_file_info64& info)
|
2017-12-29 22:45:02 +00:00
|
|
|
{
|
2023-07-17 11:12:45 +00:00
|
|
|
size_t cbData = sizeof(ZipPidlEntry) + wcslen(lpString) * sizeof(WCHAR);
|
|
|
|
if (cbData > MAXWORD)
|
|
|
|
return NULL;
|
|
|
|
|
2017-12-29 22:45:02 +00:00
|
|
|
ZipPidlEntry* pidl = (ZipPidlEntry*)SHAlloc(cbData + sizeof(WORD));
|
|
|
|
if (!pidl)
|
|
|
|
return NULL;
|
|
|
|
|
2018-04-21 10:50:05 +00:00
|
|
|
ZeroMemory(pidl, cbData + sizeof(WORD));
|
|
|
|
|
2023-07-17 11:12:45 +00:00
|
|
|
pidl->cb = (WORD)cbData;
|
2017-12-29 22:45:02 +00:00
|
|
|
pidl->MagicType = 'z';
|
|
|
|
pidl->ZipType = Type;
|
|
|
|
|
|
|
|
if (Type != ZIP_PIDL_DIRECTORY)
|
|
|
|
{
|
|
|
|
pidl->CompressedSize = info.compressed_size;
|
|
|
|
pidl->UncompressedSize = info.uncompressed_size;
|
|
|
|
pidl->DosDate = info.dosDate;
|
2019-02-27 21:18:52 +00:00
|
|
|
pidl->Password = info.flag & MINIZIP_PASSWORD_FLAG;
|
2017-12-29 22:45:02 +00:00
|
|
|
}
|
|
|
|
|
2023-07-17 11:12:45 +00:00
|
|
|
wcscpy(pidl->Name, lpString);
|
|
|
|
*(WORD*)((char*)pidl + cbData) = 0; // The end of an ITEMIDLIST
|
2017-12-29 22:45:02 +00:00
|
|
|
|
|
|
|
return (LPITEMIDLIST)pidl;
|
|
|
|
}
|
|
|
|
|
|
|
|
const ZipPidlEntry* _ZipFromIL(LPCITEMIDLIST pidl)
|
|
|
|
{
|
|
|
|
const ZipPidlEntry* zipPidl = (const ZipPidlEntry*)pidl;
|
|
|
|
if (zipPidl->MagicType == 'z')
|
|
|
|
return zipPidl;
|
|
|
|
return NULL;
|
|
|
|
}
|