2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
11 // See http://www.pkware.com/documents/casestudies/APPNOTE.TXT
12 #define ZIP_LOCAL_HEADER 0x04034b50
13 #define ZIP_DATA_RECORD_HEADER 0x08074b50
14 #define ZIP_CENTRAL_HEADER 0x02014b50
15 #define ZIP_END_CENTRAL_HEADER 0x06054b50
16 #define ZIP_SPLIT_ARCHIVE_HEADER 0x30304b50
20 #define ECDREC_SIZE 22
29 static const std::string
PATH_TRAVERSAL(R
"_((^|\/|\\)\.{2}($|\/|\\))_");
32 unsigned int header
= 0;
33 unsigned short version
= 0;
34 unsigned short flags
= 0;
35 unsigned short method
= 0;
36 unsigned short mod_time
= 0;
37 unsigned short mod_date
= 0;
38 unsigned int crc32
= 0;
39 unsigned int csize
= 0; // compressed size
40 unsigned int usize
= 0; // uncompressed size
41 unsigned short flength
= 0; // filename length
42 unsigned short elength
= 0; // extra field length (local file header)
43 unsigned short eclength
= 0; // extra field length (central file header)
44 unsigned short clength
= 0; // file comment length (central file header)
45 unsigned int lhdrOffset
= 0; // Relative offset of local header
46 int64_t offset
= 0; // offset in file to compressed data
61 bool GetZipList(const CURL
& url
, std::vector
<SZipEntry
>& items
);
62 bool GetZipEntry(const CURL
& url
, SZipEntry
& item
);
63 bool ExtractArchive(const std::string
& strArchive
, const std::string
& strPath
);
64 bool ExtractArchive(const CURL
& archive
, const std::string
& strPath
);
65 void release(const std::string
& strPath
); // release resources used by list zip
66 static void readHeader(const char* buffer
, SZipEntry
& info
);
67 static void readCHeader(const char* buffer
, SZipEntry
& info
);
69 std::map
<std::string
,std::vector
<SZipEntry
> > mZipMap
;
70 std::map
<std::string
,int64_t> mZipDate
;
73 static T
ReadUnaligned(const void* mem
)
76 std::memcpy(&var
, mem
, sizeof(T
));
81 extern CZipManager g_ZipManager
;