Class PathUtilities
Contains utility functions related to file paths
Namespace: WeaverCore.Utilities
Assembly: WeaverCore.dll
Syntax
public static class PathUtilities
Fields
| Edit this page View SourceAssetsFolder
A path to the "Assets" directory in the Unity Project
Declaration
public static readonly DirectoryInfo AssetsFolder
Field Value
Type | Description |
---|---|
DirectoryInfo |
ProjectFolder
A path to the Project directory in the Unity Project
Declaration
public static readonly DirectoryInfo ProjectFolder
Field Value
Type | Description |
---|---|
DirectoryInfo |
reservedCharacters
A list of reserved characters that can't exist in a file's name
Declaration
public static readonly string reservedCharacters
Field Value
Type | Description |
---|---|
string |
Methods
| Edit this page View SourceAddSlash(DirectoryInfo)
Ensures that a slash is added to the end of a path
Declaration
public static string AddSlash(this DirectoryInfo directory)
Parameters
Type | Name | Description |
---|---|---|
DirectoryInfo | directory |
Returns
Type | Description |
---|---|
string | Returns the path but with a slash at the end |
AddSlash(string)
Ensures that a slash is added to the end of a path
Declaration
public static string AddSlash(string path)
Parameters
Type | Name | Description |
---|---|---|
string | path | The path to add a slash to |
Returns
Type | Description |
---|---|
string | Returns the path but with a slash at the end |
ConvertToAssetPath(string)
Converts an absolute path into a path that is relative to the "Assets" folder
Declaration
public static string ConvertToAssetPath(string path)
Parameters
Type | Name | Description |
---|---|---|
string | path | The absolute path to be made relative |
Returns
Type | Description |
---|---|
string | Returns the path but relative to the "Assets" folder |
ConvertToProjectPath(string)
Converts an absolute path into a path that is relative to the Project folder
Declaration
public static string ConvertToProjectPath(string path)
Parameters
Type | Name | Description |
---|---|---|
string | path | The absolute path to be made relative |
Returns
Type | Description |
---|---|
string | Returns the path but relative to the Project folder |
GetFileName(FileInfo)
Returns the file name (without the extension)
Declaration
public static string GetFileName(this FileInfo info)
Parameters
Type | Name | Description |
---|---|---|
FileInfo | info |
Returns
Type | Description |
---|---|
string |
MakePathRelative(DirectoryInfo, string)
Makes a global path relative to an existing directory
Declaration
public static string MakePathRelative(DirectoryInfo relativeTo, string path)
Parameters
Type | Name | Description |
---|---|---|
DirectoryInfo | relativeTo | The existing directory that the new path will be made relative to |
string | path | The path that will be made relative to the " |
Returns
Type | Description |
---|---|
string | Returns a new path that is relative to the " |
MakePathRelative(string, string)
Makes a global path relative to an existing directory
Declaration
public static string MakePathRelative(string relativeTo, string path)
Parameters
Type | Name | Description |
---|---|---|
string | relativeTo | The existing directory that the new path will be made relative to |
string | path | The path that will be made relative to the " |
Returns
Type | Description |
---|---|
string | Returns a new path that is relative to the " |
MakePathsRelative(DirectoryInfo, IEnumerable<string>)
Makes a list of paths relative to an existing directory
Declaration
public static IEnumerable<string> MakePathsRelative(DirectoryInfo relativeTo, IEnumerable<string> paths)
Parameters
Type | Name | Description |
---|---|---|
DirectoryInfo | relativeTo | The existing directory that the new path will be made relative to |
IEnumerable<string> | paths | The paths that will be made relative to the " |
Returns
Type | Description |
---|---|
IEnumerable<string> | Returns a list of new paths that are relative to the " |
MakePathsRelative(string, IEnumerable<string>)
Makes a list of paths relative to an existing directory
Declaration
public static IEnumerable<string> MakePathsRelative(string relativeTo, IEnumerable<string> paths)
Parameters
Type | Name | Description |
---|---|---|
string | relativeTo | The existing directory that the new path will be made relative to |
IEnumerable<string> | paths | The paths that will be made relative to the " |
Returns
Type | Description |
---|---|
IEnumerable<string> | Returns a list of new paths that are relative to the " |
RemoveURIEscapeChars(string)
Converts url escape characters into their actual characters
Declaration
public static string RemoveURIEscapeChars(string input)
Parameters
Type | Name | Description |
---|---|---|
string | input | The path to filter |
Returns
Type | Description |
---|---|
string | Returns the path but with the URL Escape Characters removed |
Remarks
See here for more info on URL Escape Characters : https://docs.microfocus.com/OMi/10.62/Content/OMi/ExtGuide/ExtApps/URL_encoding.htm
ReplaceSlashes(string)
Replaces all backslashes () with forward slashes (/) to make the path work with some unity functions
Declaration
public static string ReplaceSlashes(string path)
Parameters
Type | Name | Description |
---|---|---|
string | path |
Returns
Type | Description |
---|---|
string |