MCPcopy Create free account
hub / github.com/GDRETools/gdsdecomp / get_sha256_for_dir

Function get_sha256_for_dir

utility/common.cpp:425–454  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

423}
424namespace {
425String get_sha256_for_dir(const String &dir) {
426 auto p_file = Glob::rglob(dir.path_join("**/*"), true);
427
428 CryptoCore::SHA256Context ctx;
429 ctx.start();
430
431 for (int i = 0; i < p_file.size(); i++) {
432 Ref<FileAccess> f = FileAccess::open(p_file[i], FileAccess::READ);
433 if (f.is_null()) {
434 continue;
435 }
436
437 unsigned char step[32768];
438
439 while (true) {
440 uint64_t br = f->get_buffer(step, 32768);
441 if (br > 0) {
442 ctx.update(step, br);
443 }
444 if (br < 4096) {
445 break;
446 }
447 }
448 }
449
450 unsigned char hash[32];
451 ctx.finish(hash);
452
453 return String::hex_encode_buffer(hash, 32);
454}
455} //namespace
456
457String gdre::get_sha256(const String &dir) {

Callers 1

get_sha256Method · 0.85

Calls 5

finishMethod · 0.80
startMethod · 0.45
sizeMethod · 0.45
get_bufferMethod · 0.45
updateMethod · 0.45

Tested by

no test coverage detected