MCPcopy Create free account
hub / github.com/BYVoid/OpenCC / ReadBinaryFile

Function ReadBinaryFile

src/ResourceProvider.cpp:184–210  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

182
183#if defined(_WIN32) || defined(_WIN64)
184std::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
213struct ZipEntry {

Callers 2

MappedZipArchiveMethod · 0.85
GetResourceMethod · 0.85

Calls 5

freadFunction · 0.85
WideFromUtf8Function · 0.70
emptyMethod · 0.45
dataMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected