MCPcopy Create free account
hub / github.com/OpenFodder/openfodder / FileMD5

Method FileMD5

Source/ResourceMan.cpp:318–339  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

316}
317
318std::string cResourceMan::FileMD5(const std::string& pFile) {
319 md5_context ctx;
320 unsigned char MD5[16];
321
322 auto File = FileRead(pFile);
323 if (!File->size())
324 return "";
325
326 md5_starts(&ctx);
327 md5_update(&ctx, File->data(), (uint32)File->size());
328 md5_finish(&ctx, MD5);
329
330 std::string FinalMD5;
331 FinalMD5.reserve(32);
332
333 for (size_t i = 0; i != 16; ++i) {
334 FinalMD5 += "0123456789ABCDEF"[MD5[i] / 16];
335 FinalMD5 += "0123456789ABCDEF"[MD5[i] % 16];
336 }
337
338 return FinalMD5;
339}
340
341std::string cResourceMan::FileReadStr(const std::string& pFile) {
342

Callers

nothing calls this directly

Calls 4

md5_startsFunction · 0.85
md5_updateFunction · 0.85
md5_finishFunction · 0.85
sizeMethod · 0.45

Tested by

no test coverage detected