diff options
| author | Juan Linietsky | 2017-12-27 15:21:18 -0300 |
|---|---|---|
| committer | Juan Linietsky | 2017-12-27 15:22:04 -0300 |
| commit | 988d29bdd8f1d6fc74280cceb76a8b4edb54138d (patch) | |
| tree | f4906ca14548d0ed8b83f76a8496574ff4fdd24c /core | |
| parent | 5c636875e418fbf055ddcff8d682639d1f096d05 (diff) | |
| download | godot-988d29bdd8f1d6fc74280cceb76a8b4edb54138d.tar.gz godot-988d29bdd8f1d6fc74280cceb76a8b4edb54138d.tar.zst godot-988d29bdd8f1d6fc74280cceb76a8b4edb54138d.zip | |
Diffstat (limited to 'core')
| -rw-r--r-- | core/os/file_access.cpp | 31 | ||||
| -rw-r--r-- | core/os/file_access.h | 1 |
2 files changed, 32 insertions, 0 deletions
diff --git a/core/os/file_access.cpp b/core/os/file_access.cpp index 20c1221f2..133c70b67 100644 --- a/core/os/file_access.cpp +++ b/core/os/file_access.cpp @@ -569,6 +569,37 @@ String FileAccess::get_md5(const String &p_file) { return ret; } +String FileAccess::get_multiple_md5(const Vector<String> &p_file) { + + MD5_CTX md5; + MD5Init(&md5); + + for (int i = 0; i < p_file.size(); i++) { + FileAccess *f = FileAccess::open(p_file[i], READ); + ERR_CONTINUE(!f); + + unsigned char step[32768]; + + while (true) { + + int br = f->get_buffer(step, 32768); + if (br > 0) { + + MD5Update(&md5, step, br); + } + if (br < 4096) + break; + } + memdelete(f); + } + + MD5Final(&md5); + + String ret = String::md5(md5.digest); + + return ret; +} + String FileAccess::get_sha256(const String &p_file) { FileAccess *f = FileAccess::open(p_file, READ); diff --git a/core/os/file_access.h b/core/os/file_access.h index 6fda3d966..548d7b71f 100644 --- a/core/os/file_access.h +++ b/core/os/file_access.h @@ -155,6 +155,7 @@ public: static String get_md5(const String &p_file); static String get_sha256(const String &p_file); + static String get_multiple_md5(const Vector<String> &p_file); static Vector<uint8_t> get_file_as_array(const String &p_path); |
