mirror of
https://github.com/godotengine/godot.git
synced 2025-12-07 22:00:10 +00:00
Merge pull request #109433 from KoBeWi/hastension
Add `has_extension()` method to String
This commit is contained in:
commit
ae9732139a
29 changed files with 46 additions and 48 deletions
|
|
@ -231,8 +231,7 @@ Error ResourceFormatSaverCrypto::save(const Ref<Resource> &p_resource, const Str
|
|||
if (cert.is_valid()) {
|
||||
err = cert->save(p_path);
|
||||
} else if (key.is_valid()) {
|
||||
String el = p_path.get_extension().to_lower();
|
||||
err = key->save(p_path, el == "pub");
|
||||
err = key->save(p_path, p_path.has_extension("pub"));
|
||||
} else {
|
||||
ERR_FAIL_V(ERR_INVALID_PARAMETER);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -888,8 +888,7 @@ bool GDExtensionResourceLoader::handles_type(const String &p_type) const {
|
|||
}
|
||||
|
||||
String GDExtensionResourceLoader::get_resource_type(const String &p_path) const {
|
||||
String el = p_path.get_extension().to_lower();
|
||||
if (el == "gdextension") {
|
||||
if (p_path.has_extension("gdextension")) {
|
||||
return "GDExtension";
|
||||
}
|
||||
return "";
|
||||
|
|
|
|||
|
|
@ -1593,8 +1593,7 @@ bool ResourceFormatLoaderJSON::handles_type(const String &p_type) const {
|
|||
}
|
||||
|
||||
String ResourceFormatLoaderJSON::get_resource_type(const String &p_path) const {
|
||||
String el = p_path.get_extension().to_lower();
|
||||
if (el == "json") {
|
||||
if (p_path.has_extension("json")) {
|
||||
return "JSON";
|
||||
}
|
||||
return "";
|
||||
|
|
|
|||
|
|
@ -105,7 +105,6 @@ Error ResourceSaver::save(const Ref<Resource> &p_resource, const String &p_path,
|
|||
}
|
||||
ERR_FAIL_COND_V_MSG(path.is_empty(), ERR_INVALID_PARAMETER, "Can't save resource to empty path. Provide non-empty path or a Resource with non-empty resource_path.");
|
||||
|
||||
String extension = path.get_extension();
|
||||
Error err = ERR_FILE_UNRECOGNIZED;
|
||||
|
||||
for (int i = 0; i < saver_count; i++) {
|
||||
|
|
|
|||
|
|
@ -368,7 +368,7 @@ bool TranslationLoaderPO::handles_type(const String &p_type) const {
|
|||
}
|
||||
|
||||
String TranslationLoaderPO::get_resource_type(const String &p_path) const {
|
||||
if (p_path.get_extension().to_lower() == "po" || p_path.get_extension().to_lower() == "mo") {
|
||||
if (p_path.has_extension("po") || p_path.has_extension("mo")) {
|
||||
return "Translation";
|
||||
}
|
||||
return "";
|
||||
|
|
|
|||
|
|
@ -519,6 +519,8 @@ public:
|
|||
String get_basename() const;
|
||||
String path_join(const String &p_path) const;
|
||||
char32_t unicode_at(int p_idx) const;
|
||||
bool has_extension(const char *p_ext) const { return get_extension().to_lower() == p_ext; }
|
||||
bool has_extension(const String &p_ext) const { return get_extension().to_lower() == p_ext; }
|
||||
|
||||
CharString ascii(bool p_allow_extended = false) const;
|
||||
// Parse an ascii string.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue