| 176 | } |
| 177 | |
| 178 | void 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 | |
| 201 | cnpy::NpyArray load_the_npy_file(FILE* fp) |
| 202 | { |
nothing calls this directly
no outgoing calls
no test coverage detected