| 182 | |
| 183 | #if defined(_WIN32) || defined(_WIN64) |
| 184 | std::vector<unsigned char> ReadBinaryFile(const std::string& path) { |
| 185 | FILE* file = _wfopen(internal::WideFromUtf8(path).c_str(), L"rb"); |
| 186 | if (file == nullptr) { |
| 187 | throw FileNotFound(path); |
| 188 | } |
| 189 | if (fseek(file, 0, SEEK_END) != 0) { |
| 190 | fclose(file); |
| 191 | throw FileNotFound(path); |
| 192 | } |
| 193 | const long fileSize = ftell(file); |
| 194 | if (fileSize < 0) { |
| 195 | fclose(file); |
| 196 | throw FileNotFound(path); |
| 197 | } |
| 198 | if (fseek(file, 0, SEEK_SET) != 0) { |
| 199 | fclose(file); |
| 200 | throw FileNotFound(path); |
| 201 | } |
| 202 | std::vector<unsigned char> data(static_cast<size_t>(fileSize)); |
| 203 | if (!data.empty() && |
| 204 | fread(data.data(), 1, data.size(), file) != data.size()) { |
| 205 | fclose(file); |
| 206 | throw FileNotFound(path); |
| 207 | } |
| 208 | fclose(file); |
| 209 | return data; |
| 210 | } |
| 211 | #endif |
| 212 | |
| 213 | struct ZipEntry { |
no test coverage detected