summaryrefslogtreecommitdiff
path: root/core/io
diff options
context:
space:
mode:
Diffstat (limited to 'core/io')
-rw-r--r--core/io/resource_format_binary.cpp10
-rw-r--r--core/io/resource_format_binary.h1
-rw-r--r--core/io/resource_format_xml.cpp14
-rw-r--r--core/io/resource_format_xml.h1
-rw-r--r--core/io/resource_saver.h1
5 files changed, 23 insertions, 4 deletions
diff --git a/core/io/resource_format_binary.cpp b/core/io/resource_format_binary.cpp
index 33f4cafedd..e2371fe24f 100644
--- a/core/io/resource_format_binary.cpp
+++ b/core/io/resource_format_binary.cpp
@@ -1751,7 +1751,10 @@ Error ResourceFormatSaverBinaryInstance::save(const String &p_path,const RES& p_
skip_editor=p_flags&ResourceSaver::FLAG_OMIT_EDITOR_PROPERTIES;
bundle_resources=p_flags&ResourceSaver::FLAG_BUNDLE_RESOURCES;
big_endian=p_flags&ResourceSaver::FLAG_SAVE_BIG_ENDIAN;
+ takeover_paths=p_flags&ResourceSaver::FLAG_REPLACE_SUBRESOURCE_PATHS;
+ if (!p_path.begins_with("res://"))
+ takeover_paths=false;
local_path=p_path.get_base_dir();
//bin_meta_idx = get_string_index("__bin_meta__"); //is often used, so create
@@ -1841,9 +1844,12 @@ Error ResourceFormatSaverBinaryInstance::save(const String &p_path,const RES& p_
for(List<RES>::Element *E=saved_resources.front();E;E=E->next()) {
RES r = E->get();
- if (r->get_path()=="" || r->get_path().find("::")!=-1)
+ if (r->get_path()=="" || r->get_path().find("::")!=-1) {
save_unicode_string("local://"+itos(ofs_pos.size()));
- else
+ if (takeover_paths) {
+ r->set_path(p_path+"::"+itos(ofs_pos.size()),true);
+ }
+ } else
save_unicode_string(r->get_path()); //actual external
ofs_pos.push_back(f->get_pos());
f->store_64(0); //offset in 64 bits
diff --git a/core/io/resource_format_binary.h b/core/io/resource_format_binary.h
index bd33fee82c..cc26357bfb 100644
--- a/core/io/resource_format_binary.h
+++ b/core/io/resource_format_binary.h
@@ -125,6 +125,7 @@ class ResourceFormatSaverBinaryInstance {
bool bundle_resources;
bool skip_editor;
bool big_endian;
+ bool takeover_paths;
int bin_meta_idx;
FileAccess *f;
String magic;
diff --git a/core/io/resource_format_xml.cpp b/core/io/resource_format_xml.cpp
index dae95097d3..e6eede7de6 100644
--- a/core/io/resource_format_xml.cpp
+++ b/core/io/resource_format_xml.cpp
@@ -2505,6 +2505,10 @@ Error ResourceFormatSaverXMLInstance::save(const String &p_path,const RES& p_res
relative_paths=p_flags&ResourceSaver::FLAG_RELATIVE_PATHS;
skip_editor=p_flags&ResourceSaver::FLAG_OMIT_EDITOR_PROPERTIES;
bundle_resources=p_flags&ResourceSaver::FLAG_BUNDLE_RESOURCES;
+ takeover_paths=p_flags&ResourceSaver::FLAG_REPLACE_SUBRESOURCE_PATHS;
+ if (!p_path.begins_with("res://")) {
+ takeover_paths=false;
+ }
depth=0;
// save resources
@@ -2541,8 +2545,14 @@ Error ResourceFormatSaverXMLInstance::save(const String &p_path,const RES& p_res
enter_tag("main_resource",""); //bundled
else if (res->get_path().length() && res->get_path().find("::") == -1 )
enter_tag("resource","type=\""+res->get_type()+"\" path=\""+res->get_path()+"\""); //bundled
- else
- enter_tag("resource","type=\""+res->get_type()+"\" path=\"local://"+itos(resource_map[res])+"\"");
+ else {
+ int idx = resource_map[res];
+ enter_tag("resource","type=\""+res->get_type()+"\" path=\"local://"+itos(idx)+"\"");
+ if (takeover_paths) {
+ res->set_path(p_path+"::"+itos(idx),true);
+ }
+
+ }
write_string("\n",false);
diff --git a/core/io/resource_format_xml.h b/core/io/resource_format_xml.h
index cfa4744915..40aaa01451 100644
--- a/core/io/resource_format_xml.h
+++ b/core/io/resource_format_xml.h
@@ -117,6 +117,7 @@ class ResourceFormatSaverXMLInstance {
+ bool takeover_paths;
bool relative_paths;
bool bundle_resources;
bool skip_editor;
diff --git a/core/io/resource_saver.h b/core/io/resource_saver.h
index fd4575c872..e307668721 100644
--- a/core/io/resource_saver.h
+++ b/core/io/resource_saver.h
@@ -74,6 +74,7 @@ public:
FLAG_OMIT_EDITOR_PROPERTIES=8,
FLAG_SAVE_BIG_ENDIAN=16,
FLAG_COMPRESS=32,
+ FLAG_REPLACE_SUBRESOURCE_PATHS=64,
};