diff --git a/src/BizHawk.Common/Extensions/PathExtensions.cs b/src/BizHawk.Common/Extensions/PathExtensions.cs
index 0d09e49f94..685cb0a7d7 100644
--- a/src/BizHawk.Common/Extensions/PathExtensions.cs
+++ b/src/BizHawk.Common/Extensions/PathExtensions.cs
@@ -52,15 +52,22 @@ namespace BizHawk.Common.PathExtensions
///
public static bool IsAbsolute(this string path)
{
+ //TODO: this code must be deleted. We can't use bespoke logic for something as squirrely as this. Find a framework way to do it.
+
if (OSTailoredCode.IsUnixHost) return path.Length >= 1 && path[0] == '/';
if (path.Contains('/')) return IsAbsolute(path.Replace('/', '\\'));
- return path.Length >= 3
- && path[2] switch
- {
- '\\' => path[1] == '\\' && ('A'.RangeTo('Z').Contains(path[0]) || 'a'.RangeTo('z').Contains(path[0])),
- '?' => path.StartsWith(@"\\?\"),
- _ => false
- };
+ if (path.Length < 3)
+ return false;
+ if (path[2] == '\\')
+ {
+ if (path[1] != '\\')
+ return false;
+ bool driveLetter = ('A'.RangeTo('Z').Contains(path[0]) || 'a'.RangeTo('z').Contains(path[0]));
+ return driveLetter;
+ }
+ if (path[2] == '?')
+ return path.StartsWith(@"\\?\");
+ return false;
}
/// iff absolute (OS-dependent)
@@ -105,16 +112,26 @@ namespace BizHawk.Common.PathExtensions
return Win32Imports.PathRelativePathTo(path, fromPath, GetPathAttribute(fromPath), toPath, GetPathAttribute(toPath))
? path.ToString()
: throw new ArgumentException("Paths must have a common prefix");
- }
-
+ }
+
/// absolute path (OS-dependent) equivalent to
///
/// unless is given, uses CWDHacks.Get/Environment.CurrentDirectory,
/// so take care when calling this after startup
///
- public static string MakeAbsolute(this string path, string? cwd = null) => path.IsAbsolute()
- ? path
- : new FileInfo($"{cwd ?? (OSTailoredCode.IsUnixHost ? Environment.CurrentDirectory : CWDHacks.Get())}/{path}").FullName; // FileInfo for normalisation ("C:\a\b\..\c" => "C:\a\c")
+ public static string MakeAbsolute(this string path, string? cwd = null)
+ {
+ if (path.IsAbsolute())
+ return path;
+ else
+ {
+ // FileInfo for normalisation ("C:\a\b\..\c" => "C:\a\c")
+ var mycwd = cwd ?? (OSTailoredCode.IsUnixHost ? Environment.CurrentDirectory : CWDHacks.Get());
+ var finalpath = $"{mycwd}/{path}";
+ var fi = new FileInfo(finalpath);
+ return fi.FullName;
+ }
+ }
/// the absolute path equivalent to which contains %exe% (expanded) as a prefix
///