You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-04 12:00:25 +00:00
[Export] Convert uid:// names to res:// when exporting files.
This commit is contained in:
@@ -255,6 +255,10 @@ Error EditorExportPlatform::_save_pack_file(void *p_userdata, const String &p_pa
|
|||||||
PackData *pd = (PackData *)p_userdata;
|
PackData *pd = (PackData *)p_userdata;
|
||||||
|
|
||||||
String simplified_path = p_path.simplify_path();
|
String simplified_path = p_path.simplify_path();
|
||||||
|
if (simplified_path.begins_with("uid://")) {
|
||||||
|
simplified_path = ResourceUID::uid_to_path(simplified_path).simplify_path();
|
||||||
|
print_verbose(vformat(R"(UID referenced exported file name "%s" was replaced with "%s".)", p_path, simplified_path));
|
||||||
|
}
|
||||||
|
|
||||||
SavedData sd;
|
SavedData sd;
|
||||||
sd.path_utf8 = simplified_path.trim_prefix("res://").utf8();
|
sd.path_utf8 = simplified_path.trim_prefix("res://").utf8();
|
||||||
@@ -349,7 +353,13 @@ Error EditorExportPlatform::_save_pack_patch_file(void *p_userdata, const String
|
|||||||
Error EditorExportPlatform::_save_zip_file(void *p_userdata, const String &p_path, const Vector<uint8_t> &p_data, int p_file, int p_total, const Vector<String> &p_enc_in_filters, const Vector<String> &p_enc_ex_filters, const Vector<uint8_t> &p_key, uint64_t p_seed) {
|
Error EditorExportPlatform::_save_zip_file(void *p_userdata, const String &p_path, const Vector<uint8_t> &p_data, int p_file, int p_total, const Vector<String> &p_enc_in_filters, const Vector<String> &p_enc_ex_filters, const Vector<uint8_t> &p_key, uint64_t p_seed) {
|
||||||
ERR_FAIL_COND_V_MSG(p_total < 1, ERR_PARAMETER_RANGE_ERROR, "Must select at least one file to export.");
|
ERR_FAIL_COND_V_MSG(p_total < 1, ERR_PARAMETER_RANGE_ERROR, "Must select at least one file to export.");
|
||||||
|
|
||||||
String path = p_path.replace_first("res://", "");
|
String path = p_path.simplify_path();
|
||||||
|
if (path.begins_with("uid://")) {
|
||||||
|
path = ResourceUID::uid_to_path(path).simplify_path();
|
||||||
|
print_verbose(vformat(R"(UID referenced exported file name "%s" was replaced with "%s".)", p_path, path));
|
||||||
|
}
|
||||||
|
|
||||||
|
path = path.replace_first("res://", "");
|
||||||
|
|
||||||
ZipData *zd = (ZipData *)p_userdata;
|
ZipData *zd = (ZipData *)p_userdata;
|
||||||
|
|
||||||
@@ -1013,7 +1023,13 @@ Error EditorExportPlatform::_script_save_file(void *p_userdata, const String &p_
|
|||||||
Callable cb = ((ScriptCallbackData *)p_userdata)->file_cb;
|
Callable cb = ((ScriptCallbackData *)p_userdata)->file_cb;
|
||||||
ERR_FAIL_COND_V(!cb.is_valid(), FAILED);
|
ERR_FAIL_COND_V(!cb.is_valid(), FAILED);
|
||||||
|
|
||||||
Variant path = p_path;
|
String simplified_path = p_path.simplify_path();
|
||||||
|
if (simplified_path.begins_with("uid://")) {
|
||||||
|
simplified_path = ResourceUID::uid_to_path(simplified_path).simplify_path();
|
||||||
|
print_verbose(vformat(R"(UID referenced exported file name "%s" was replaced with "%s".)", p_path, simplified_path));
|
||||||
|
}
|
||||||
|
|
||||||
|
Variant path = simplified_path;
|
||||||
Variant data = p_data;
|
Variant data = p_data;
|
||||||
Variant file = p_file;
|
Variant file = p_file;
|
||||||
Variant total = p_total;
|
Variant total = p_total;
|
||||||
|
|||||||
@@ -803,7 +803,12 @@ Error EditorExportPlatformAndroid::save_apk_so(void *p_userdata, const SharedObj
|
|||||||
|
|
||||||
Error EditorExportPlatformAndroid::save_apk_file(void *p_userdata, const String &p_path, const Vector<uint8_t> &p_data, int p_file, int p_total, const Vector<String> &p_enc_in_filters, const Vector<String> &p_enc_ex_filters, const Vector<uint8_t> &p_key, uint64_t p_seed) {
|
Error EditorExportPlatformAndroid::save_apk_file(void *p_userdata, const String &p_path, const Vector<uint8_t> &p_data, int p_file, int p_total, const Vector<String> &p_enc_in_filters, const Vector<String> &p_enc_ex_filters, const Vector<uint8_t> &p_key, uint64_t p_seed) {
|
||||||
APKExportData *ed = static_cast<APKExportData *>(p_userdata);
|
APKExportData *ed = static_cast<APKExportData *>(p_userdata);
|
||||||
const String path = ResourceUID::ensure_path(p_path);
|
|
||||||
|
String path = p_path.simplify_path();
|
||||||
|
if (path.begins_with("uid://")) {
|
||||||
|
path = ResourceUID::uid_to_path(path).simplify_path();
|
||||||
|
print_verbose(vformat(R"(UID referenced exported file name "%s" was replaced with "%s".)", p_path, path));
|
||||||
|
}
|
||||||
const String dst_path = path.replace_first("res://", "assets/");
|
const String dst_path = path.replace_first("res://", "assets/");
|
||||||
|
|
||||||
store_in_apk(ed, dst_path, p_data, _should_compress_asset(path, p_data) ? Z_DEFLATED : 0);
|
store_in_apk(ed, dst_path, p_data, _should_compress_asset(path, p_data) ? Z_DEFLATED : 0);
|
||||||
|
|||||||
@@ -171,8 +171,14 @@ Error store_string_at_path(const String &p_path, const String &p_data) {
|
|||||||
// This method will be called ONLY when gradle build is enabled.
|
// This method will be called ONLY when gradle build is enabled.
|
||||||
Error rename_and_store_file_in_gradle_project(void *p_userdata, const String &p_path, const Vector<uint8_t> &p_data, int p_file, int p_total, const Vector<String> &p_enc_in_filters, const Vector<String> &p_enc_ex_filters, const Vector<uint8_t> &p_key, uint64_t p_seed) {
|
Error rename_and_store_file_in_gradle_project(void *p_userdata, const String &p_path, const Vector<uint8_t> &p_data, int p_file, int p_total, const Vector<String> &p_enc_in_filters, const Vector<String> &p_enc_ex_filters, const Vector<uint8_t> &p_key, uint64_t p_seed) {
|
||||||
CustomExportData *export_data = static_cast<CustomExportData *>(p_userdata);
|
CustomExportData *export_data = static_cast<CustomExportData *>(p_userdata);
|
||||||
const String path = ResourceUID::ensure_path(p_path);
|
|
||||||
|
String path = p_path.simplify_path();
|
||||||
|
if (path.begins_with("uid://")) {
|
||||||
|
path = ResourceUID::uid_to_path(path).simplify_path();
|
||||||
|
print_verbose(vformat(R"(UID referenced exported file name "%s" was replaced with "%s".)", p_path, path));
|
||||||
|
}
|
||||||
const String dst_path = path.replace_first("res://", export_data->assets_directory + "/");
|
const String dst_path = path.replace_first("res://", export_data->assets_directory + "/");
|
||||||
|
|
||||||
print_verbose("Saving project files from " + path + " into " + dst_path);
|
print_verbose("Saving project files from " + path + " into " + dst_path);
|
||||||
Error err = store_file_at_path(dst_path, p_data);
|
Error err = store_file_at_path(dst_path, p_data);
|
||||||
return err;
|
return err;
|
||||||
|
|||||||
Reference in New Issue
Block a user