Interface IStaticDirectory
Describes a logical file in a static file system. This is used to abstract access to static files read from an assembly's embedded resources or potentially from other sources using Linux style paths.
This is currently used to emulate a tree of IStaticDirectory and IStaticFile instances loaded from an assembly's embedded resources via the GetResourceFileSystem(Assembly, string) extension method.
note
IMPORTANT: Implementations need to be thread-safe.
note
In general, file and directory name lookup case sensitivity should probably be case insensitive for most purposes but this is an implementation specific detail.
Namespace: Neon.IO
Assembly: Neon.Common.dll
Syntax
public interface IStaticDirectory
Properties
Name
Returns the directory name.
Declaration
string Name { get; }
Property Value
| Type | Description |
|---|---|
| string |
Parent
Returns a reference to the parent directory or null if this is the root directory
for a static file system.
Declaration
IStaticDirectory Parent { get; }
Property Value
| Type | Description |
|---|---|
| IStaticDirectory |
Path
Returns the fully qualified Linux style path for the static directory relative to the static root directory.
Declaration
string Path { get; }
Property Value
| Type | Description |
|---|---|
| string |
Methods
GetDirectories(string, SearchOption)
Returns the directories beneath the current directory, optionally matching directories by name as well as optionally searching for directories recursively.
Declaration
IEnumerable<IStaticDirectory> GetDirectories(string searchPattern = null, SearchOption options = SearchOption.TopDirectoryOnly)
Parameters
| Type | Name | Description |
|---|---|---|
| string | searchPattern | Optionally specifies a directory name pattern using standard file system wildcards like [*] and [?]. This defaults to including all directories. |
| SearchOption | options | Optionally require a recursive search. This defaults to TopDirectoryOnly. |
Returns
| Type | Description |
|---|---|
| IEnumerable<IStaticDirectory> | The set of matching directories. |
GetDirectory(string)
Gets a directory via a Linux style path. This path can be absolute relative to the root directory or it can be relative to the current directory.
note
Relative paths including /../ notation to move up a directory or ./ to specify the current directory are not supported.
Declaration
IStaticDirectory GetDirectory(string path)
Parameters
| Type | Name | Description |
|---|---|---|
| string | path | The file path (absolute or relative). |
Returns
| Type | Description |
|---|---|
| IStaticDirectory | The directory. |
Exceptions
| Type | Condition |
|---|---|
| FileNotFoundException | Thrown if the directory doesn't exist. |
GetFile(string)
Gets a file via a Linux style path. This path can be absolute relative to the root directory or it can be relative to the current directory.
note
Relative paths including /../ notation to move up a directory or ./ to specify the current directory are not supported.
Declaration
IStaticFile GetFile(string path)
Parameters
| Type | Name | Description |
|---|---|---|
| string | path | The file path (absolute or relative). |
Returns
| Type | Description |
|---|---|
| IStaticFile | The file. |
Exceptions
| Type | Condition |
|---|---|
| FileNotFoundException | Thrown if the file doesn't exist. |
GetFiles(string, SearchOption)
Returns the files beneath the current directory, optionally matching files by name as well as optionally searching recursively searching subdirectories..
Declaration
IEnumerable<IStaticFile> GetFiles(string searchPattern = null, SearchOption options = SearchOption.TopDirectoryOnly)
Parameters
| Type | Name | Description |
|---|---|---|
| string | searchPattern | Optionally specifies a file name pattern using standard file system wildcards like [*] and [?]. This defaults to including all files. |
| SearchOption | options | Optionally requires a recursive search. This defaults to TopDirectoryOnly. |
Returns
| Type | Description |
|---|---|
| IEnumerable<IStaticFile> | The set of matching files. |