Class AssetsDirectory
Class containing methods for accessing assets in a directory.
Namespace: Evergine.Common.IO
Assembly: Evergine.Common.dll
Syntax
public class AssetsDirectory
Constructors
AssetsDirectory()
Initializes a new instance of the AssetsDirectory class.
Declaration
public AssetsDirectory()
AssetsDirectory(IFileSystemProvider)
Initializes a new instance of the AssetsDirectory class.
Declaration
public AssetsDirectory(IFileSystemProvider fileSystemProvider)
Parameters
| Type | Name | Description |
|---|---|---|
| IFileSystemProvider | fileSystemProvider | The file system provider. |
AssetsDirectory(IFileSystemProvider, string)
Initializes a new instance of the AssetsDirectory class.
Declaration
public AssetsDirectory(IFileSystemProvider fileSystemProvider, string rootPath)
Parameters
| Type | Name | Description |
|---|---|---|
| IFileSystemProvider | fileSystemProvider | The file system provider. |
| string | rootPath | The root path of the assets directory. |
AssetsDirectory(string)
Initializes a new instance of the AssetsDirectory class.
Declaration
public AssetsDirectory(string rootPath)
Parameters
| Type | Name | Description |
|---|---|---|
| string | rootPath | The root path of the assets directory. |
Fields
DefaultFolderName
The default asset folder name.
Declaration
public const string DefaultFolderName = "Content"
Field Value
| Type | Description |
|---|---|
| string |
Properties
RootPath
Gets the root path of the assets directory.
Declaration
public string RootPath { get; }
Property Value
| Type | Description |
|---|---|
| string |
Methods
EnumerateDirectories(string)
Returns an enumerable collection of subdirectories from the specified relative path in the assets directory.
Declaration
public IEnumerable<string> EnumerateDirectories(string path)
Parameters
| Type | Name | Description |
|---|---|---|
| string | path | The relative path in the assets directory. |
Returns
| Type | Description |
|---|---|
| IEnumerable<string> | An enumerable collection of subdirectories from the specified relative path in the assets directory, or an empty enumerable collection if no directories are found. |
Remarks
If an existing directory is empty, it will be excluded from the enumerable collection.
EnumerateDirectories(string, string)
Returns an enumerable collection of subdirectories that match the specified search pattern in the specified relative path in the assets directory.
Declaration
public IEnumerable<string> EnumerateDirectories(string path, string searchPattern)
Parameters
| Type | Name | Description |
|---|---|---|
| string | path | The relative path in the assets directory. |
| string | searchPattern | The search string to match against the names of files in the path. This parameter can contain a combination of valid literal path and wildcard (* and ?) characters, but it doesn't support regular expressions. |
Returns
| Type | Description |
|---|---|
| IEnumerable<string> | An enumerable collection of subdirectories in the specified relative path in the assets directory that match the specified criteria, or an empty enumerable collection if no directories are found. |
Remarks
If an existing directory is empty, it will be discarded from the enumerable collection.
EnumerateDirectories(string, string, SearchOption)
Returns an enumerable collection of subdirectories that match the specified search pattern in the specified relative path in the assets directory and optionally searches subdirectories.
Declaration
public virtual IEnumerable<string> EnumerateDirectories(string path, string searchPattern, SearchOption searchOption)
Parameters
| Type | Name | Description |
|---|---|---|
| string | path | The relative path in the assets directory. |
| string | searchPattern | The search string to match against the names of files in the path. This parameter can contain a combination of valid literal path and wildcard (* and ?) characters, but it doesn't support regular expressions. |
| SearchOption | searchOption | One of the enumeration values that specifies whether the search operation should include all subdirectories or only the current directory. |
Returns
| Type | Description |
|---|---|
| IEnumerable<string> | An enumerable collection of subdirectories in the specified relative path in the assets directory that match the specified criteria, or an empty enumerable collection if no directories are found. |
Remarks
If an existing directory is empty, it will be discarded from the enumerable collection.
EnumerateFiles(string)
Returns the names of files in the specified relative path in the assets directory.
Declaration
public IEnumerable<string> EnumerateFiles(string path)
Parameters
| Type | Name | Description |
|---|---|---|
| string | path | The relative path in the assets directory. |
Returns
| Type | Description |
|---|---|
| IEnumerable<string> | An enumerable collection of names for the files in the specified relative path in the assets directory, or an empty enumerable collection if no files are found. |
EnumerateFiles(string, string)
Returns the names of files that match the specified search pattern in the specified relative path in the assets directory.
Declaration
public IEnumerable<string> EnumerateFiles(string path, string searchPattern)
Parameters
| Type | Name | Description |
|---|---|---|
| string | path | The relative path in the assets directory. |
| string | searchPattern | The search string to match against the names of files in the path. This parameter can contain a combination of valid literal path and wildcard (* and ?) characters, but it doesn't support regular expressions. |
Returns
| Type | Description |
|---|---|
| IEnumerable<string> | An enumerable collection of names for the files in the specified relative path in the assets directory that match the specified criteria, or an empty enumerable collection if no files are found. |
EnumerateFiles(string, string, SearchOption)
Returns the names of files that match the specified search pattern in the specified relative path in the assets directory, and optionally searches subdirectories.
Declaration
public virtual IEnumerable<string> EnumerateFiles(string path, string searchPattern, SearchOption searchOption)
Parameters
| Type | Name | Description |
|---|---|---|
| string | path | The relative path in the assets directory. |
| string | searchPattern | The search string to match against the names of files in the path. This parameter can contain a combination of valid literal path and wildcard (* and ?) characters, but it doesn't support regular expressions. |
| SearchOption | searchOption | One of the enumeration values that specifies whether the search operation should include all subdirectories or only the current directory. |
Returns
| Type | Description |
|---|---|
| IEnumerable<string> | An enumerable collection of names for the files in the specified relative path in the assets directory that match the specified criteria, or an empty enumerable collection if no files are found. |
Exists(string)
Determines whether the specified asset file exists.
Declaration
public virtual bool Exists(string path)
Parameters
| Type | Name | Description |
|---|---|---|
| string | path | The asset file path to check. |
Returns
| Type | Description |
|---|---|
| bool |
|
GetFullPath(string)
Gets the full file path given a relative one.
Declaration
protected virtual string GetFullPath(string path)
Parameters
| Type | Name | Description |
|---|---|---|
| string | path | The relative path in the assets directory. |
Returns
| Type | Description |
|---|---|
| string | The full file path in the assets directory. |
Open(string)
Opens the specified asset file.
Declaration
public virtual AssetStream Open(string path)
Parameters
| Type | Name | Description |
|---|---|---|
| string | path | The relative path to the asset file. |
Returns
| Type | Description |
|---|---|
| AssetStream | The result. |
ReadAsStringAsync(string)
Reads all characters from the specified asset file asynchronously and returns them as a single string.
Declaration
public virtual Task<string> ReadAsStringAsync(string path)
Parameters
| Type | Name | Description |
|---|---|---|
| string | path | The relative path to the asset file. |
Returns
| Type | Description |
|---|---|
| Task<string> | A task that represents the asynchronous read operation. The value of the TResult parameter contains a string with the characters from the specified asset file. |
UpdateRootPath(string)
Updates the root path.
Declaration
public void UpdateRootPath(string rootPath)
Parameters
| Type | Name | Description |
|---|---|---|
| string | rootPath | The new root path. |