5 * Copyright (C) 2005-2013 Team XBMC
8 * This Program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2, or (at your option)
13 * This Program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with XBMC; see the file COPYING. If not, see
20 * <http://www.gnu.org/licenses/>.
24 // See http://www.pkware.com/documents/casestudies/APPNOTE.TXT
25 #define ZIP_LOCAL_HEADER 0x04034b50
26 #define ZIP_CENTRAL_HEADER 0x02014b50
27 #define ZIP_END_CENTRAL_HEADER 0x06054b50
30 #define ECDREC_SIZE 22
32 #include "utils/StdString.h"
40 unsigned short version
;
42 unsigned short method
;
43 unsigned short mod_time
;
44 unsigned short mod_date
;
46 unsigned int csize
; // compressed size
47 unsigned int usize
; // uncompressed size
48 unsigned short flength
; // filename length
49 unsigned short elength
; // extra field length (local file header)
50 unsigned short eclength
; // extra field length (central file header)
51 unsigned short clength
; // file comment length (central file header)
52 unsigned int lhdrOffset
; // Relative offset of local header
53 int64_t offset
; // offset in file to compressed data
76 SZipEntry(const SZipEntry
& SNewItem
)
78 memcpy(&header
,&SNewItem
.header
,sizeof(unsigned int));
79 memcpy(&version
,&SNewItem
.version
,sizeof(unsigned short));
80 memcpy(&flags
,&SNewItem
.flags
,sizeof(unsigned short));
81 memcpy(&method
,&SNewItem
.method
,sizeof(unsigned short));
82 memcpy(&mod_time
,&SNewItem
.mod_time
,sizeof(unsigned short));
83 memcpy(&mod_date
,&SNewItem
.mod_date
,sizeof(unsigned short));
84 memcpy(&crc32
,&SNewItem
.crc32
,sizeof(unsigned int));
85 memcpy(&csize
,&SNewItem
.csize
,sizeof(unsigned int));
86 memcpy(&usize
,&SNewItem
.usize
,sizeof(unsigned int));
87 memcpy(&flength
,&SNewItem
.flength
,sizeof(unsigned short));
88 memcpy(&elength
,&SNewItem
.elength
,sizeof(unsigned short));
89 memcpy(&eclength
,&SNewItem
.eclength
,sizeof(unsigned short));
90 memcpy(&clength
,&SNewItem
.clength
,sizeof(unsigned short));
91 memcpy(&lhdrOffset
,&SNewItem
.lhdrOffset
,sizeof(unsigned int));
92 memcpy(&offset
,&SNewItem
.offset
,sizeof(int64_t));
93 memcpy(name
,SNewItem
.name
,255*sizeof(char));
103 bool GetZipList(const CStdString
& strPath
, std::vector
<SZipEntry
>& items
);
104 bool GetZipEntry(const CStdString
& strPath
, SZipEntry
& item
);
105 bool ExtractArchive(const CStdString
& strArchive
, const CStdString
& strPath
);
106 void CleanUp(const CStdString
& strArchive
, const CStdString
& strPath
); // deletes extracted archive. use with care!
107 void release(const CStdString
& strPath
); // release resources used by list zip
108 static void readHeader(const char* buffer
, SZipEntry
& info
);
109 static void readCHeader(const char* buffer
, SZipEntry
& info
);
111 std::map
<CStdString
,std::vector
<SZipEntry
> > mZipMap
;
112 std::map
<CStdString
,int64_t> mZipDate
;
115 extern CZipManager g_ZipManager
;