mirror of
https://github.com/Ale32bit/Capy64.git
synced 2025-01-18 10:36:44 +00:00
Bugfix crash on invalid path chars
This commit is contained in:
parent
993b7f43f3
commit
e0afdf177c
1 changed files with 3 additions and 0 deletions
|
@ -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);
|
||||||
|
|
Loading…
Reference in a new issue