diff options
author | Juan Linietsky <juan@godotengine.org> | 2017-12-27 15:21:18 -0300 |
---|---|---|
committer | Juan Linietsky <juan@godotengine.org> | 2017-12-27 15:22:04 -0300 |
commit | 988d29bdd8f1d6fc74280cceb76a8b4edb54138d (patch) | |
tree | f4906ca14548d0ed8b83f76a8496574ff4fdd24c /core/os | |
parent | 5c636875e418fbf055ddcff8d682639d1f096d05 (diff) |
Reimport now checks source path changes and imported files and their md5, fixes #14728
Diffstat (limited to 'core/os')
-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 20c1221f2b..133c70b671 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 6fda3d9668..548d7b71f1 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); |