Fix C# string.IsAbsPath()

(cherry picked from commit b5eea5cfd4)
This commit is contained in:
Zae 2020-09-23 13:10:27 +08:00 committed by Rémi Verschelde
parent cf45fa7f36
commit e5b357cfb1
No known key found for this signature in database
GPG key ID: C3336907360768E1

View file

@ -448,7 +448,12 @@ namespace Godot
// </summary>
public static bool IsAbsPath(this string instance)
{
return System.IO.Path.IsPathRooted(instance);
if (string.IsNullOrEmpty(instance))
return false;
else if (instance.Length > 1)
return instance[0] == '/' || instance[0] == '\\' || instance.Contains(":/") || instance.Contains(":\\");
else
return instance[0] == '/' || instance[0] == '\\';
}
// <summary>
@ -456,7 +461,7 @@ namespace Godot
// </summary>
public static bool IsRelPath(this string instance)
{
return !System.IO.Path.IsPathRooted(instance);
return !IsAbsPath(instance);
}
// <summary>