forked from AlexxEG/BSA_Browser
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Normalize directory separator characters
- Loading branch information
Showing
4 changed files
with
37 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
using System.IO; | ||
|
||
namespace SharpBSABA2.Utils | ||
{ | ||
public static class PathUtils | ||
{ | ||
/// <summary> | ||
/// Returns the path with the directory separator character normalized to the platform's default. | ||
/// </summary> | ||
/// <param name="path">The path to normalize.</param> | ||
public static string NormalizePath(string path) => NormalizePath(path, Path.DirectorySeparatorChar); | ||
|
||
/// <summary> | ||
/// Returns the path with the directory separator character normalized to the specified character. | ||
/// </summary> | ||
/// <param name="path">The path to normalize.</param> | ||
/// <param name="directorySeparatorChar">The character to normalize the directory separator to.</param> | ||
public static string NormalizePath(string path, char directorySeparatorChar) | ||
{ | ||
// Replace forward slashes with backward slashes | ||
path = path.Replace('/', directorySeparatorChar); | ||
|
||
// Replace backward slashes with forward slashes | ||
path = path.Replace('\\', directorySeparatorChar); | ||
|
||
return path; | ||
} | ||
} | ||
} |