zip.patch
| UnZip.cpp (working copy) | ||
|---|---|---|
| 40 | 40 |
for(int i = 0; i < entries; i++) {
|
| 41 | 41 |
if(zip->Get32le() != 0x02014b50 && zip->IsEof()) |
| 42 | 42 |
return; |
| 43 |
File& f = file.Add();
|
|
| 43 |
File f;
|
|
| 44 | 44 |
zip->Get16le(); |
| 45 | 45 |
zip->Get16le(); |
| 46 | 46 |
f.bit = zip->Get16le(); // general purpose bit flag |
| ... | ... | |
| 58 | 58 |
zip->Get32le(); // external file attributes |
| 59 | 59 |
f.offset = zip->Get32le(); |
| 60 | 60 |
f.path = zip->Get(fnlen); |
| 61 |
file.Add(f); |
|
| 61 | 62 |
zip->SeekCur(extralen + commentlen); |
| 62 | 63 |
if(zip->IsEof() || zip->IsError()) |
| 63 | 64 |
return; |
| ... | ... | |
| 141 | 142 |
return ReadFile(ss, progress) ? ss.GetResult() : String::GetVoid(); |
| 142 | 143 |
} |
| 143 | 144 |
|
| 145 |
String UnZip::ReadFile(const char* path, Gate<int, int> progress) |
|
| 146 |
{
|
|
| 147 |
for(int i = 0; i < file.GetCount(); i++) |
|
| 148 |
{
|
|
| 149 |
if(file[i].path.IsEqual(path)) |
|
| 150 |
{
|
|
| 151 |
Seek(i); |
|
| 152 |
return ReadFile( progress ); |
|
| 153 |
} |
|
| 154 |
} |
|
| 155 |
|
|
| 156 |
return String::GetVoid(); |
|
| 157 |
} |
|
| 158 |
|
|
| 159 |
Vector<String> UnZip::Search(String pattern) |
|
| 160 |
{
|
|
| 161 |
Vector<String> v; |
|
| 162 |
for(const auto& f: file) |
|
| 163 |
{
|
|
| 164 |
if(!f.path.EndsWith("/") && PatternMatch(pattern, f.path))
|
|
| 165 |
{
|
|
| 166 |
v.Add(f.path); |
|
| 167 |
} |
|
| 168 |
} |
|
| 169 |
|
|
| 170 |
return v; |
|
| 171 |
} |
|
| 172 |
|
|
| 173 |
|
|
| 144 | 174 |
void UnZip::Create(Stream& _zip) |
| 145 | 175 |
{
|
| 146 | 176 |
zip = &_zip; |
| zip.h (working copy) | ||
|---|---|---|
| 50 | 50 |
void SkipFile() { current++; }
|
| 51 | 51 |
bool ReadFile(Stream& out, Gate<int, int> progress = Null); |
| 52 | 52 |
String ReadFile(Gate<int, int> progress = Null); |
| 53 |
String ReadFile(const char* path, Gate<int, int> progress = Null); |
|
| 54 |
Vector<String> Search(String pattern); |
|
| 53 | 55 |
|
| 54 | 56 |
dword GetPos() const; |
| 55 | 57 |
|