You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-12 13:20:55 +00:00
Fix get_base_dir windows top level directory logic
This is a fix for https://github.com/godotengine/godot/issues/52048
This commit is contained in:
@@ -4329,23 +4329,39 @@ bool String::is_rel_path() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
String String::get_base_dir() const {
|
String String::get_base_dir() const {
|
||||||
int basepos = find(":/");
|
int end = 0;
|
||||||
if (basepos == -1) {
|
|
||||||
basepos = find(":\\");
|
// url scheme style base
|
||||||
|
int basepos = find("://");
|
||||||
|
if (basepos != -1) {
|
||||||
|
end = basepos + 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// windows top level directory base
|
||||||
|
if (end == 0) {
|
||||||
|
basepos = find(":/");
|
||||||
|
if (basepos == -1) {
|
||||||
|
basepos = find(":\\");
|
||||||
|
}
|
||||||
|
if (basepos != -1) {
|
||||||
|
end = basepos + 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// unix root directory base
|
||||||
|
if (end == 0) {
|
||||||
|
if (begins_with("/")) {
|
||||||
|
end = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
String rs;
|
String rs;
|
||||||
String base;
|
String base;
|
||||||
if (basepos != -1) {
|
if (end != 0) {
|
||||||
int end = basepos + 3;
|
|
||||||
rs = substr(end, length());
|
rs = substr(end, length());
|
||||||
base = substr(0, end);
|
base = substr(0, end);
|
||||||
} else {
|
} else {
|
||||||
if (begins_with("/")) {
|
rs = *this;
|
||||||
rs = substr(1, length());
|
|
||||||
base = "/";
|
|
||||||
} else {
|
|
||||||
rs = *this;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int sep = MAX(rs.rfind("/"), rs.rfind("\\"));
|
int sep = MAX(rs.rfind("/"), rs.rfind("\\"));
|
||||||
|
|||||||
Reference in New Issue
Block a user