Browse Source

Merge pull request #18520 from paulloz/gdscript-api-string-path

fix API string path
Rémi Verschelde 7 years ago
parent
commit
f86a67c4d1
3 changed files with 5 additions and 5 deletions
  1. 1 1
      core/io/image_loader.cpp
  2. 1 1
      core/io/resource_saver.cpp
  3. 3 3
      core/ustring.cpp

+ 1 - 1
core/io/image_loader.cpp

@@ -37,7 +37,7 @@ bool ImageFormatLoader::recognize(const String &p_extension) const {
 	get_recognized_extensions(&extensions);
 	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;
 	}
 

+ 1 - 1
core/io/resource_saver.cpp

@@ -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()) {
 
-			if (E->get().nocasecmp_to(extension.get_extension()) == 0)
+			if (E->get().nocasecmp_to(extension) == 0)
 				recognized = true;
 		}
 

+ 3 - 3
core/ustring.cpp

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