| 423 | } |
| 424 | namespace { |
| 425 | String 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 | |
| 457 | String gdre::get_sha256(const String &dir) { |
no test coverage detected