From e0afdf177c488c1311a73d5077de9f5a333c51f6 Mon Sep 17 00:00:00 2001 From: Ale32bit Date: Thu, 31 Aug 2023 16:24:36 +0200 Subject: [PATCH] Bugfix crash on invalid path chars --- Capy64/Runtime/Libraries/FileSystemLib.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Capy64/Runtime/Libraries/FileSystemLib.cs b/Capy64/Runtime/Libraries/FileSystemLib.cs index 398248c..2a98aad 100644 --- a/Capy64/Runtime/Libraries/FileSystemLib.cs +++ b/Capy64/Runtime/Libraries/FileSystemLib.cs @@ -134,6 +134,9 @@ public class FileSystemLib : IComponent // Get drive root (C:\ for Windows, / for *nix) var rootPath = Path.GetFullPath(Path.GetPathRoot("/") ?? "/"); + var invalidPathChars = Path.GetInvalidPathChars(); + path = invalidPathChars.Aggregate(path, (current, invalidChar) => current.Replace(invalidChar, ' ')); + // Join path to rootPath and resolves to absolute path // Relative paths are resolved here (es. ../ and ./) var absolutePath = Path.GetFullPath(path, rootPath);