Browse Source

Merge pull request #42259 from zaevi/fix-mono-IsAbsPath

Fix C# string.IsAbsPath()
Rémi Verschelde 5 years ago
parent
commit
72aaf81518
1 changed files with 7 additions and 2 deletions
  1. 7 2
      modules/mono/glue/GodotSharp/GodotSharp/Core/StringExtensions.cs

+ 7 - 2
modules/mono/glue/GodotSharp/GodotSharp/Core/StringExtensions.cs

@@ -440,7 +440,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>
@@ -448,7 +453,7 @@ namespace Godot
         // </summary>
         public static bool IsRelPath(this string instance)
         {
-            return !System.IO.Path.IsPathRooted(instance);
+            return !IsAbsPath(instance);
         }
 
         // <summary>