summaryrefslogtreecommitdiffstats
path: root/core/io
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2024-09-26 12:45:42 +0200
committerRémi Verschelde <rverschelde@gmail.com>2024-09-26 12:45:42 +0200
commit2912cb99756dede609548503eeb3f6f1a2f2dfbf (patch)
treeb1c092f0ae2943ae5cfa1161f1442d2cbd91102f /core/io
parent991e6c92abd26435169ad7ea0df2622685cac6d1 (diff)
parentd3be030ea6f3e295603ccf6cc9080a1d32051332 (diff)
downloadredot-engine-2912cb99756dede609548503eeb3f6f1a2f2dfbf.tar.gz
Merge pull request #97118 from mihe/patch-exports
Add ability to export patch packs
Diffstat (limited to 'core/io')
-rw-r--r--core/io/file_access_pack.cpp16
-rw-r--r--core/io/file_access_pack.h3
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);