MCPcopy Index your code
hub / github.com/assaultcube/AC / loopi

Function loopi

source/src/zip.cpp:118–165  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

116 uchar *buf = new uchar[size], *src = buf;
117 if(!f->seek(offset, SEEK_SET) || (int)f->read(buf, size) != size) { delete[] buf; return false; }
118 loopi(entries)
119 {
120 if(src + ZIP_FILE_SIZE > &buf[size]) break;
121
122 zipfileheader hdr;
123 hdr.signature = lilswap(*(uint *)src); src += 4;
124 hdr.version = lilswap(*(ushort *)src); src += 2;
125 hdr.needversion = lilswap(*(ushort *)src); src += 2;
126 hdr.flags = lilswap(*(ushort *)src); src += 2;
127 hdr.compression = lilswap(*(ushort *)src); src += 2;
128 hdr.modtime = lilswap(*(ushort *)src); src += 2;
129 hdr.moddate = lilswap(*(ushort *)src); src += 2;
130 hdr.crc32 = lilswap(*(uint *)src); src += 4;
131 hdr.compressedsize = lilswap(*(uint *)src); src += 4;
132 hdr.uncompressedsize = lilswap(*(uint *)src); src += 4;
133 hdr.namelength = lilswap(*(ushort *)src); src += 2;
134 hdr.extralength = lilswap(*(ushort *)src); src += 2;
135 hdr.commentlength = lilswap(*(ushort *)src); src += 2;
136 hdr.disknumber = lilswap(*(ushort *)src); src += 2;
137 hdr.internalattribs = lilswap(*(ushort *)src); src += 2;
138 hdr.externalattribs = lilswap(*(uint *)src); src += 4;
139 hdr.offset = lilswap(*(uint *)src); src += 4;
140 if(hdr.signature != ZIP_FILE_SIGNATURE) break;
141 if(!hdr.namelength /*|| !hdr.uncompressedsize */|| (hdr.compression && (hdr.compression != Z_DEFLATED || !hdr.compressedsize)))
142 {
143 src += hdr.namelength + hdr.extralength + hdr.commentlength;
144 continue;
145 }
146 if(src + hdr.namelength > &buf[size]) break;
147
148 string pname;
149 int namelen = min((int)hdr.namelength, (int)sizeof(pname)-1);
150 memcpy(pname, src, namelen);
151 pname[namelen] = '\0';
152 path(pname);
153 char *name = newstring(pname);
154
155 zipfile &zf = files.add();
156 zf.name = name;
157 zf.header = hdr.offset;
158 zf.size = hdr.uncompressedsize;
159 zf.compressedsize = hdr.compression ? hdr.compressedsize : 0;
160#ifndef STANDALONE
161 if(dbgzip) conoutf("file %s, size %d, compress %d, flags %x", name, hdr.uncompressedsize, hdr.compression, hdr.flags);
162#endif
163
164 src += hdr.namelength + hdr.extralength + hdr.commentlength;
165 }
166 delete[] buf;
167
168 return files.length() > 0;

Callers 15

resetanimMethod · 0.70
resetstatsMethod · 0.70
respawnMethod · 0.70
playerentMethod · 0.70
respawnMethod · 0.70
write_APP1infoMethod · 0.70
~keymMethod · 0.70
serverinfoMethod · 0.70
votedisplayinfoMethod · 0.70
render_worldFunction · 0.70
initloggingFunction · 0.70
exitloggingFunction · 0.70

Calls 6

lilswapFunction · 0.85
minFunction · 0.85
pathFunction · 0.85
newstringFunction · 0.85
conoutfFunction · 0.70
addMethod · 0.45

Tested by

no test coverage detected