MCPcopy Create free account
hub / github.com/assaultcube/AC / readlocalfileheader

Function readlocalfileheader

source/src/zip.cpp:171–192  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

169}
170
171static bool readlocalfileheader(stream *f, ziplocalfileheader &h, uint offset)
172{
173 f->seek(offset, SEEK_SET);
174 uchar buf[ZIP_LOCAL_FILE_SIZE];
175 if(f->read(buf, ZIP_LOCAL_FILE_SIZE) != ZIP_LOCAL_FILE_SIZE)
176 return false;
177 uchar *src = buf;
178 h.signature = lilswap(*(uint *)src); src += 4;
179 h.version = lilswap(*(ushort *)src); src += 2;
180 h.flags = lilswap(*(ushort *)src); src += 2;
181 h.compression = lilswap(*(ushort *)src); src += 2;
182 h.modtime = lilswap(*(ushort *)src); src += 2;
183 h.moddate = lilswap(*(ushort *)src); src += 2;
184 h.crc32 = lilswap(*(uint *)src); src += 4;
185 h.compressedsize = lilswap(*(uint *)src); src += 4;
186 h.uncompressedsize = lilswap(*(uint *)src); src += 4;
187 h.namelength = lilswap(*(ushort *)src); src += 2;
188 h.extralength = lilswap(*(ushort *)src); src += 2;
189 if(h.signature != ZIP_LOCAL_FILE_SIGNATURE) return false;
190 // h.uncompressedsize or h.compressedsize may be zero - so don't validate
191 return true;
192}
193
194// stream interface
195

Callers 1

openMethod · 0.85

Calls 3

lilswapFunction · 0.85
seekMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected