Search Results for

    Show / Hide Table of Contents

    Class SafePath

    Safe version of C# 'Path' class utilizing UniTask for async operations. Path operations with safety checks and utility methods.

    Inheritance
    object
    SafePath
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: Glitch9
    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
    Type Name Description
    string fullPath
    int index
    string fallbackDir
    Returns
    Type Description
    string
    | Edit this page View Source

    Combine(params string[])

    Declaration
    public static string Combine(params string[] paths)
    Parameters
    Type Name Description
    string[] paths
    Returns
    Type Description
    string
    | Edit this page View Source

    GetTemporaryCacheFilePath(string, MimeType)

    Declaration
    public static string GetTemporaryCacheFilePath(string fileName = null, MimeType contentType = null)
    Parameters
    Type Name Description
    string fileName
    MimeType contentType
    Returns
    Type Description
    string
    | Edit this page View Source

    GetUniqueFileName(string, NamingRule)

    Declaration
    public static string GetUniqueFileName(string tag, NamingRule namingRule)
    Parameters
    Type Name Description
    string tag
    NamingRule namingRule
    Returns
    Type Description
    string
    | 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
    Type Description
    string
    | Edit this page View Source

    HasAnyExtension(string, params string[])

    Declaration
    public static bool HasAnyExtension(string path, params string[] extensions)
    Parameters
    Type Name Description
    string path
    string[] extensions
    Returns
    Type Description
    bool
    | Edit this page View Source

    HasExtension(string, string)

    Declaration
    public static bool HasExtension(string path, string extension)
    Parameters
    Type Name Description
    string path
    string extension
    Returns
    Type Description
    bool
    | 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
    Type Description
    bool
    | 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
    Type Description
    string
    | Edit this page View Source

    NormalizeFileNameWithinPath(string)

    Declaration
    public static string NormalizeFileNameWithinPath(string path)
    Parameters
    Type Name Description
    string path
    Returns
    Type Description
    string
    | 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
    Type Description
    string
    | Edit this page View Source

    RemoveDuplicateExtensions(string)

    Declaration
    public static string RemoveDuplicateExtensions(string path)
    Parameters
    Type Name Description
    string path
    Returns
    Type Description
    string
    • Edit this page
    • View Source
    In this article
    Back to top AI DevKit Documentation