diff options
Diffstat (limited to 'core/io/resource_uid.cpp')
-rw-r--r-- | core/io/resource_uid.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/core/io/resource_uid.cpp b/core/io/resource_uid.cpp index c14121a53b..946bc524e5 100644 --- a/core/io/resource_uid.cpp +++ b/core/io/resource_uid.cpp @@ -34,6 +34,7 @@ #include "core/crypto/crypto_core.h" #include "core/io/dir_access.h" #include "core/io/file_access.h" +#include "core/io/resource_loader.h" // These constants are off by 1, causing the 'z' and '9' characters never to be used. // This cannot be fixed without breaking compatibility; see GH-83843. @@ -139,6 +140,21 @@ void ResourceUID::remove_id(ID p_id) { unique_ids.erase(p_id); } +String ResourceUID::uid_to_path(const String &p_uid) { + return singleton->get_id_path(singleton->text_to_id(p_uid)); +} + +String ResourceUID::path_to_uid(const String &p_path) { + return singleton->id_to_text(ResourceLoader::get_resource_uid(p_path)); +} + +String ResourceUID::ensure_path(const String &p_uid_or_path) { + if (p_uid_or_path.begins_with("uid://")) { + return uid_to_path(p_uid_or_path); + } + return p_uid_or_path; +} + Error ResourceUID::save_to_cache() { String cache_file = get_cache_file(); if (!FileAccess::exists(cache_file)) { |