Bugfix crash on invalid path chars

This commit is contained in:
Ale32bit 2023-08-31 16:24:36 +02:00
parent 993b7f43f3
commit e0afdf177c

View file

@ -134,6 +134,9 @@ public class FileSystemLib : IComponent
// Get drive root (C:\ for Windows, / for *nix) // Get drive root (C:\ for Windows, / for *nix)
var rootPath = Path.GetFullPath(Path.GetPathRoot("/") ?? "/"); 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 // Join path to rootPath and resolves to absolute path
// Relative paths are resolved here (es. ../ and ./) // Relative paths are resolved here (es. ../ and ./)
var absolutePath = Path.GetFullPath(path, rootPath); var absolutePath = Path.GetFullPath(path, rootPath);