Class SafePath
Safe version of C# 'Path' class utilizing UniTask for async operations.
Path operations with safety checks and utility methods.
Assembly: Glitch9.dll
Syntax
public static class SafePath
Methods
|
Edit this page
View Source
AppendIndex(string, int, string)
Declaration
public static string AppendIndex(string fullPath, int index, string fallbackDir = null)
Parameters
Returns
|
Edit this page
View Source
Combine(params string[])
Declaration
public static string Combine(params string[] paths)
Parameters
| Type |
Name |
Description |
| string[] |
paths |
|
Returns
|
Edit this page
View Source
GetTemporaryCacheFilePath(string, MimeType)
Declaration
public static string GetTemporaryCacheFilePath(string fileName = null, MimeType contentType = null)
Parameters
Returns
|
Edit this page
View Source
GetUniqueFileName(string, NamingRule)
Declaration
public static string GetUniqueFileName(string tag, NamingRule namingRule)
Parameters
Returns
|
Edit this page
View Source
GetUniqueFilePath(string)
Generates a unique file path by appending an incrementing suffix if the original path already exists.
Declaration
public static string GetUniqueFilePath(string originalPath)
Parameters
| Type |
Name |
Description |
| string |
originalPath |
|
Returns
|
Edit this page
View Source
HasAnyExtension(string, params string[])
Declaration
public static bool HasAnyExtension(string path, params string[] extensions)
Parameters
Returns
|
Edit this page
View Source
HasExtension(string, string)
Declaration
public static bool HasExtension(string path, string extension)
Parameters
Returns
|
Edit this page
View Source
HasFileName(string)
Checks if the given path includes a file name (i.e., has an extension).
Declaration
public static bool HasFileName(string path)
Parameters
| Type |
Name |
Description |
| string |
path |
|
Returns
|
Edit this page
View Source
NormalizeFileName(string)
Normalizes a file name by replacing invalid characters with underscores.
Declaration
public static string NormalizeFileName(string name)
Parameters
| Type |
Name |
Description |
| string |
name |
|
Returns
|
Edit this page
View Source
NormalizeFileNameWithinPath(string)
Declaration
public static string NormalizeFileNameWithinPath(string path)
Parameters
| Type |
Name |
Description |
| string |
path |
|
Returns
|
Edit this page
View Source
NormalizeSeparators(string)
Common mistake when dealing with file paths in Unity is using two slashes (//) instead of one (/).
Often occurs when combining two paths and one of them is already a slash in the end.
This method fixes that by replacing all backslashes () with slashes (/) and removing double slashes (//).
Declaration
public static string NormalizeSeparators(string path)
Parameters
| Type |
Name |
Description |
| string |
path |
|
Returns
|
Edit this page
View Source
RemoveDuplicateExtensions(string)
Declaration
public static string RemoveDuplicateExtensions(string path)
Parameters
| Type |
Name |
Description |
| string |
path |
|
Returns