Class FileSystemExtensions
Extensions for the file system stuff.
Inherited Members
Namespace: FubarDev.FtpServer.FileSystem
Assembly: FubarDev.FtpServer.Abstractions.dll
Syntax
public static class FileSystemExtensions
Methods
| Improve this Doc View SourceClone(Stack<IUnixDirectoryEntry>)
Clone the stack of directory entries.
Declaration
public static Stack<IUnixDirectoryEntry> Clone(this Stack<IUnixDirectoryEntry> path)
Parameters
Type | Name | Description |
---|---|---|
Stack<IUnixDirectoryEntry> | path | The stack of directory entries to clone. |
Returns
Type | Description |
---|---|
Stack<IUnixDirectoryEntry> | the cloned |
CombinePath(Nullable<String>, IEnumerable<String>)
Appends parts to a path.
Declaration
public static string CombinePath(string? path, IEnumerable<string> parts)
Parameters
Type | Name | Description |
---|---|---|
Nullable<String> | path | The path to append to. |
IEnumerable<String> | parts | The parts to append. |
Returns
Type | Description |
---|---|
String | The combined path. |
CombinePath(Nullable<String>, String[])
Appends parts to a path.
Declaration
public static string CombinePath(string? path, params string[] parts)
Parameters
Type | Name | Description |
---|---|---|
Nullable<String> | path | The path to append to. |
String[] | parts | The parts to append. |
Returns
Type | Description |
---|---|
String | The combined path. |
GetDirectoryAsync(IUnixFileSystem, Stack<IUnixDirectoryEntry>, IReadOnlyList<String>, CancellationToken)
Get the directory for the given pathElements
.
Declaration
public static Task<IUnixDirectoryEntry? > GetDirectoryAsync(this IUnixFileSystem fileSystem, Stack<IUnixDirectoryEntry> currentPath, IReadOnlyList<string> pathElements, CancellationToken cancellationToken)
Parameters
Type | Name | Description |
---|---|---|
IUnixFileSystem | fileSystem | The file system to get the directory for. |
Stack<IUnixDirectoryEntry> | currentPath | The current path. |
IReadOnlyList<String> | pathElements | The (absolute or relative) path to get the directory for. |
CancellationToken | cancellationToken | The cancellation token. |
Returns
Type | Description |
---|---|
Task<Nullable<IUnixDirectoryEntry>> | The found IUnixDirectoryEntry or |
GetDirectoryAsync(IUnixFileSystem, Stack<IUnixDirectoryEntry>, Nullable<String>, CancellationToken)
Get the directory for the given path
.
Declaration
public static Task<IUnixDirectoryEntry? > GetDirectoryAsync(this IUnixFileSystem fileSystem, Stack<IUnixDirectoryEntry> currentPath, string? path, CancellationToken cancellationToken)
Parameters
Type | Name | Description |
---|---|---|
IUnixFileSystem | fileSystem | The file system to get the directory for. |
Stack<IUnixDirectoryEntry> | currentPath | The current path. |
Nullable<String> | path | The (absolute or relative) path to get the directory for. |
CancellationToken | cancellationToken | The cancellation token. |
Returns
Type | Description |
---|---|
Task<Nullable<IUnixDirectoryEntry>> | The found IUnixDirectoryEntry or |
GetFullPath(IEnumerable<IUnixDirectoryEntry>)
Returns the path
as string.
Declaration
public static string GetFullPath(this IEnumerable<IUnixDirectoryEntry> path)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<IUnixDirectoryEntry> | path | The path to convert to string. |
Returns
Type | Description |
---|---|
String | The |
GetFullPath(Stack<IUnixDirectoryEntry>)
Returns the path
as string.
Declaration
public static string GetFullPath(this Stack<IUnixDirectoryEntry> path)
Parameters
Type | Name | Description |
---|---|---|
Stack<IUnixDirectoryEntry> | path | The path to convert to string. |
Returns
Type | Description |
---|---|
String | The |
GetFullPath(Stack<IUnixDirectoryEntry>, Nullable<String>)
Returns the path
as string.
Declaration
public static string GetFullPath(this Stack<IUnixDirectoryEntry> path, string? fileName)
Parameters
Type | Name | Description |
---|---|---|
Stack<IUnixDirectoryEntry> | path | The path to convert to string. |
Nullable<String> | fileName | The file name to append to the |
Returns
Type | Description |
---|---|
String | The combination of |
GetParentPath(String)
Returns the parent path of the path
.
Declaration
public static string GetParentPath(this string path)
Parameters
Type | Name | Description |
---|---|---|
String | path | The path to get the parent path from. |
Returns
Type | Description |
---|---|
String | The parent path. |
IsChildOfOrSameAs(Stack<IUnixDirectoryEntry>, Stack<IUnixDirectoryEntry>, IUnixFileSystem)
Determines whether the pathToTestAsChild
is a child or the same path as pathToTestAsParent
.
Declaration
public static bool IsChildOfOrSameAs(this Stack<IUnixDirectoryEntry> pathToTestAsChild, Stack<IUnixDirectoryEntry> pathToTestAsParent, IUnixFileSystem fileSystem)
Parameters
Type | Name | Description |
---|---|---|
Stack<IUnixDirectoryEntry> | pathToTestAsChild | The path to test as child. |
Stack<IUnixDirectoryEntry> | pathToTestAsParent | The path to test as parent. |
IUnixFileSystem | fileSystem | The file system to use to compare the file names. |
Returns
Type | Description |
---|---|
Boolean | if the pathToTestAsChild is a child or the same path as pathToTestAsParent .
|
SearchDirectoryAsync(IUnixFileSystem, Stack<IUnixDirectoryEntry>, IReadOnlyList<String>, CancellationToken)
Searches for a IUnixDirectoryEntry by using the currentPath
and pathElements
.
Declaration
public static Task<SearchResult<IUnixDirectoryEntry>? > SearchDirectoryAsync(this IUnixFileSystem fileSystem, Stack<IUnixDirectoryEntry> currentPath, IReadOnlyList<string> pathElements, CancellationToken cancellationToken)
Parameters
Type | Name | Description |
---|---|---|
IUnixFileSystem | fileSystem | The underlying IUnixFileSystem. |
Stack<IUnixDirectoryEntry> | currentPath | The current path. |
IReadOnlyList<String> | pathElements | The relative path elements to search for. |
CancellationToken | cancellationToken | The cancellation token. |
Returns
Type | Description |
---|---|
Task<Nullable<SearchResult<IUnixDirectoryEntry>>> | The found IUnixDirectoryEntry. |
SearchDirectoryAsync(IUnixFileSystem, Stack<IUnixDirectoryEntry>, Nullable<String>, CancellationToken)
Searches for a IUnixDirectoryEntry by using the currentPath
and path
.
Declaration
public static Task<SearchResult<IUnixDirectoryEntry>? > SearchDirectoryAsync(this IUnixFileSystem fileSystem, Stack<IUnixDirectoryEntry> currentPath, string? path, CancellationToken cancellationToken)
Parameters
Type | Name | Description |
---|---|---|
IUnixFileSystem | fileSystem | The underlying IUnixFileSystem. |
Stack<IUnixDirectoryEntry> | currentPath | The current path. |
Nullable<String> | path | The relative path to search for. |
CancellationToken | cancellationToken | The cancellation token. |
Returns
Type | Description |
---|---|
Task<Nullable<SearchResult<IUnixDirectoryEntry>>> | The found IUnixDirectoryEntry. |
SearchEntryAsync(IUnixFileSystem, Stack<IUnixDirectoryEntry>, IReadOnlyList<String>, CancellationToken)
Searches for a IUnixFileSystemEntry by using the currentPath
and pathElements
.
Declaration
public static Task<SearchResult<IUnixFileSystemEntry>? > SearchEntryAsync(this IUnixFileSystem fileSystem, Stack<IUnixDirectoryEntry> currentPath, IReadOnlyList<string> pathElements, CancellationToken cancellationToken)
Parameters
Type | Name | Description |
---|---|---|
IUnixFileSystem | fileSystem | The underlying IUnixFileSystem. |
Stack<IUnixDirectoryEntry> | currentPath | The current path. |
IReadOnlyList<String> | pathElements | The relative path elements to search for. |
CancellationToken | cancellationToken | The cancellation token. |
Returns
Type | Description |
---|---|
Task<Nullable<SearchResult<IUnixFileSystemEntry>>> | The found IUnixFileSystemEntry. |
SearchEntryAsync(IUnixFileSystem, Stack<IUnixDirectoryEntry>, Nullable<String>, CancellationToken)
Searches for a IUnixFileSystemEntry by using the currentPath
and path
.
Declaration
public static Task<SearchResult<IUnixFileSystemEntry>? > SearchEntryAsync(this IUnixFileSystem fileSystem, Stack<IUnixDirectoryEntry> currentPath, string? path, CancellationToken cancellationToken)
Parameters
Type | Name | Description |
---|---|---|
IUnixFileSystem | fileSystem | The underlying IUnixFileSystem. |
Stack<IUnixDirectoryEntry> | currentPath | The current path. |
Nullable<String> | path | The relative path to search for. |
CancellationToken | cancellationToken | The cancellation token. |
Returns
Type | Description |
---|---|
Task<Nullable<SearchResult<IUnixFileSystemEntry>>> | The found IUnixFileSystemEntry. |
SearchFileAsync(IUnixFileSystem, Stack<IUnixDirectoryEntry>, IReadOnlyList<String>, CancellationToken)
Searches for a IUnixFileEntry by using the currentPath
and pathElements
.
Declaration
public static Task<SearchResult<IUnixFileEntry>? > SearchFileAsync(this IUnixFileSystem fileSystem, Stack<IUnixDirectoryEntry> currentPath, IReadOnlyList<string> pathElements, CancellationToken cancellationToken)
Parameters
Type | Name | Description |
---|---|---|
IUnixFileSystem | fileSystem | The underlying IUnixFileSystem. |
Stack<IUnixDirectoryEntry> | currentPath | The current path. |
IReadOnlyList<String> | pathElements | The relative path elements to search for. |
CancellationToken | cancellationToken | The cancellation token. |
Returns
Type | Description |
---|---|
Task<Nullable<SearchResult<IUnixFileEntry>>> | The found IUnixDirectoryEntry. |
SearchFileAsync(IUnixFileSystem, Stack<IUnixDirectoryEntry>, Nullable<String>, CancellationToken)
Searches for a IUnixFileEntry by using the currentPath
and path
.
Declaration
public static Task<SearchResult<IUnixFileEntry>? > SearchFileAsync(this IUnixFileSystem fileSystem, Stack<IUnixDirectoryEntry> currentPath, string? path, CancellationToken cancellationToken)
Parameters
Type | Name | Description |
---|---|---|
IUnixFileSystem | fileSystem | The underlying IUnixFileSystem. |
Stack<IUnixDirectoryEntry> | currentPath | The current path. |
Nullable<String> | path | The relative path to search for. |
CancellationToken | cancellationToken | The cancellation token. |
Returns
Type | Description |
---|---|
Task<Nullable<SearchResult<IUnixFileEntry>>> | The found IUnixDirectoryEntry. |
SplitPath(Nullable<String>)
Split the path into parts.
Declaration
public static IReadOnlyList<string> SplitPath(string? path)
Parameters
Type | Name | Description |
---|---|---|
Nullable<String> | path | The path to split. |
Returns
Type | Description |
---|---|
IReadOnlyList<String> | The parts of the path. |
ToDisplayString(Stack<IUnixDirectoryEntry>)
Returns the path
as string like GetFullPath(Stack<IUnixDirectoryEntry>), with the
difference that it doesn't add the trailing /
.
Declaration
public static string ToDisplayString(this Stack<IUnixDirectoryEntry> path)
Parameters
Type | Name | Description |
---|---|---|
Stack<IUnixDirectoryEntry> | path | The path to convert to string. |
Returns
Type | Description |
---|---|
String | The |