diff options
author | Mikael Hermansson <mikael@hermansson.io> | 2024-09-17 12:48:10 +0200 |
---|---|---|
committer | Mikael Hermansson <mikael@hermansson.io> | 2024-09-25 17:07:28 +0200 |
commit | d3be030ea6f3e295603ccf6cc9080a1d32051332 (patch) | |
tree | ea184077a368d8c447527dd8cb72f7eab1c27200 /core | |
parent | 4254946de93bab0cc1fb36a7b9039c9ec43be924 (diff) | |
download | redot-engine-d3be030ea6f3e295603ccf6cc9080a1d32051332.tar.gz |
Add ability to export patch packs
Co-authored-by: Poq Xert <poqxert@poqxert.ru>
Diffstat (limited to 'core')
-rw-r--r-- | core/io/file_access_pack.cpp | 16 | ||||
-rw-r--r-- | core/io/file_access_pack.h | 3 |
2 files changed, 19 insertions, 0 deletions
diff --git a/core/io/file_access_pack.cpp b/core/io/file_access_pack.cpp index eec27ce0aa..1340382eaa 100644 --- a/core/io/file_access_pack.cpp +++ b/core/io/file_access_pack.cpp @@ -102,6 +102,22 @@ void PackedData::add_pack_source(PackSource *p_source) { } } +uint8_t *PackedData::get_file_hash(const String &p_path) { + PathMD5 pmd5(p_path.md5_buffer()); + HashMap<PathMD5, PackedFile, PathMD5>::Iterator E = files.find(pmd5); + if (!E || E->value.offset == 0) { + return nullptr; + } + + return E->value.md5; +} + +void PackedData::clear() { + files.clear(); + _free_packed_dirs(root); + root = memnew(PackedDir); +} + PackedData *PackedData::singleton = nullptr; PackedData::PackedData() { diff --git a/core/io/file_access_pack.h b/core/io/file_access_pack.h index 595a36bca4..57b7a5f87f 100644 --- a/core/io/file_access_pack.h +++ b/core/io/file_access_pack.h @@ -111,6 +111,7 @@ private: public: void add_pack_source(PackSource *p_source); void add_path(const String &p_pkg_path, const String &p_path, uint64_t p_ofs, uint64_t p_size, const uint8_t *p_md5, PackSource *p_src, bool p_replace_files, bool p_encrypted = false); // for PackSource + uint8_t *get_file_hash(const String &p_path); void set_disabled(bool p_disabled) { disabled = p_disabled; } _FORCE_INLINE_ bool is_disabled() const { return disabled; } @@ -118,6 +119,8 @@ public: static PackedData *get_singleton() { return singleton; } Error add_pack(const String &p_path, bool p_replace_files, uint64_t p_offset); + void clear(); + _FORCE_INLINE_ Ref<FileAccess> try_open_path(const String &p_path); _FORCE_INLINE_ bool has_path(const String &p_path); |