MCPcopy Create free account
hub / github.com/NVIDIA/FasterTransformer / parse_zip_footer

Method parse_zip_footer

examples/cpp/xlnet/cnpy.cpp:178–199  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

176}
177
178void cnpy::parse_zip_footer(FILE* fp, uint16_t& nrecs, size_t& global_header_size, size_t& global_header_offset)
179{
180 std::vector<char> footer(22);
181 fseek(fp, -22, SEEK_END);
182 size_t res = fread(&footer[0], sizeof(char), 22, fp);
183 if (res != 22)
184 throw std::runtime_error("parse_zip_footer: failed fread");
185
186 uint16_t disk_no, disk_start, nrecs_on_disk, comment_len;
187 disk_no = *(uint16_t*)&footer[4];
188 disk_start = *(uint16_t*)&footer[6];
189 nrecs_on_disk = *(uint16_t*)&footer[8];
190 nrecs = *(uint16_t*)&footer[10];
191 global_header_size = *(uint32_t*)&footer[12];
192 global_header_offset = *(uint32_t*)&footer[16];
193 comment_len = *(uint16_t*)&footer[20];
194
195 assert(disk_no == 0);
196 assert(disk_start == 0);
197 assert(nrecs_on_disk == nrecs);
198 assert(comment_len == 0);
199}
200
201cnpy::NpyArray load_the_npy_file(FILE* fp)
202{

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected