fix API string path

(cherry picked from commit a35c8bbdc7)
This commit is contained in:
Paul Joannon 2018-01-11 12:59:31 +01:00 committed by Hein-Pieter van Braam
parent 4de1d0905a
commit 1d3be8c453
3 changed files with 5 additions and 5 deletions

View File

@ -37,7 +37,7 @@ bool ImageFormatLoader::recognize(const String &p_extension) const {
get_recognized_extensions(&extensions); get_recognized_extensions(&extensions);
for (List<String>::Element *E = extensions.front(); E; E = E->next()) { for (List<String>::Element *E = extensions.front(); E; E = E->next()) {
if (E->get().nocasecmp_to(p_extension.get_extension()) == 0) if (E->get().nocasecmp_to(p_extension) == 0)
return true; return true;
} }

View File

@ -56,7 +56,7 @@ Error ResourceSaver::save(const String &p_path, const RES &p_resource, uint32_t
for (List<String>::Element *E = extensions.front(); E; E = E->next()) { for (List<String>::Element *E = extensions.front(); E; E = E->next()) {
if (E->get().nocasecmp_to(extension.get_extension()) == 0) if (E->get().nocasecmp_to(extension) == 0)
recognized = true; recognized = true;
} }

View File

@ -3713,8 +3713,8 @@ String String::get_file() const {
String String::get_extension() const { String String::get_extension() const {
int pos = find_last("."); int pos = find_last(".");
if (pos < 0) if (pos < 0 || pos < MAX(find_last("/"), find_last("\\")))
return *this; return "";
return substr(pos + 1, length()); return substr(pos + 1, length());
} }
@ -3792,7 +3792,7 @@ String String::percent_decode() const {
String String::get_basename() const { String String::get_basename() const {
int pos = find_last("."); int pos = find_last(".");
if (pos < 0) if (pos < 0 || pos < MAX(find_last("/"), find_last("\\")))
return *this; return *this;
return substr(0, pos); return substr(0, pos);