Interface IIndelibleDirectory
Represents the root of a Directory that can not be deleted, where each file that is access through a directory is associated with a GUID in the directory's manifest.
When files are moved between IDirectories, the files GUID is preserved. Thus, metadata can be preserved throughout.
Namespace: Snowflake.Filesystem
Assembly: Snowflake.Framework.Primitives.dll
Syntax
public interface IIndelibleDirectory
Properties
Name
Gets the name of the directory
Declaration
string Name { get; }
Property Value
Type | Description |
---|---|
System. |
Methods
AsReadOnly()
Returns a read only view over this directory.
Declaration
IReadOnlyDirectory AsReadOnly()
Returns
Type | Description |
---|---|
IRead |
A read only view over this directory. |
ContainsDirectory(String)
Whether or not this directory contains directory as a direct child.
full path, this will truncate the path using System.
Declaration
bool ContainsDirectory(string directory)
Parameters
Type | Name | Description |
---|---|---|
System. |
directory | The name of the directory to check. |
Returns
Type | Description |
---|---|
System. |
Whether or not this directory contains the given directory. |
ContainsFile(String)
Whether or not this directory contains a file in its manifest. If provided a
full path, this will truncate the path using System.
Declaration
bool ContainsFile(string file)
Parameters
Type | Name | Description |
---|---|---|
System. |
file | The name of the file to check. |
Returns
Type | Description |
---|---|
System. |
Whether or not this directory contains the given file. |
CopyFrom(IReadOnlyFile)
Copies a file from a IFile from another IDirectory, updating the
manifests such that the resulting file has the same File
Declaration
IFile CopyFrom(IReadOnlyFile source)
Parameters
Type | Name | Description |
---|---|---|
IRead |
source | The System. |
Returns
Type | Description |
---|---|
IFile | The IFile that describes the file in the current IDirectory. |
Exceptions
Type | Condition |
---|---|
System. |
If a file with the same name exists in the target destination. |
System. |
If the source file can not be found. |
CopyFrom(IReadOnlyFile, Boolean)
Copies a file from a IFile from another IDirectory, updating the
manifests such that the resulting file has the same File
Declaration
IFile CopyFrom(IReadOnlyFile source, bool overwrite)
Parameters
Type | Name | Description |
---|---|---|
IRead |
source | The System. |
System. |
overwrite | Overwrite the file if it already exists in this IDirectory |
Returns
Type | Description |
---|---|
IFile | The IFile that describes the file in the current IDirectory. |
Exceptions
Type | Condition |
---|---|
System. |
If a file with the same name exists in the target destination and |
System. |
If the source file can not be found. |
CopyFrom(FileInfo)
Copies a file from an unmanaged System.
Declaration
IFile CopyFrom(FileInfo source)
Parameters
Type | Name | Description |
---|---|---|
System. |
source | The System. |
Returns
Type | Description |
---|---|
IFile | The IFile that describes the file in the current IDirectory. |
Exceptions
Type | Condition |
---|---|
System. |
If a file with the same name exists in the target destination. |
System. |
If the source file can not be found. |
CopyFrom(FileInfo, Boolean)
Copies a file from an unmanaged System.
Declaration
IFile CopyFrom(FileInfo source, bool overwrite)
Parameters
Type | Name | Description |
---|---|---|
System. |
source | The System. |
System. |
overwrite | Overwrite the file if it already exists in this IDirectory |
Returns
Type | Description |
---|---|
IFile | The IFile that describes the file in the current IDirectory. |
Exceptions
Type | Condition |
---|---|
System. |
If a file with the same name exists in the target destination and |
System. |
If the source file can not be found. |
CopyFromAsync(IReadOnlyFile, Boolean, CancellationToken)
Copies a file asynchronously from a IFile from another IDirectory, updating the
manifests such that the resulting file has the same File
Declaration
Task<IFile> CopyFromAsync(IReadOnlyFile source, bool overwrite, CancellationToken cancellation = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
IRead |
source | The System. |
System. |
overwrite | Overwrite the file if it already exists in this IDirectory |
System. |
cancellation | Cancellation token for the asynchronous task. |
Returns
Type | Description |
---|---|
System. |
The IRead |
Exceptions
Type | Condition |
---|---|
System. |
If a file with the same name exists in the target destination and |
System. |
If the source file can not be found. |
CopyFromAsync(IReadOnlyFile, CancellationToken)
Copies a file asynchronously from a IFile from another IDirectory, updating the
manifests such that the resulting file has the same File
Declaration
Task<IFile> CopyFromAsync(IReadOnlyFile source, CancellationToken cancellation = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
IRead |
source | The System. |
System. |
cancellation | Cancellation token for the asynchronous task. |
Returns
Type | Description |
---|---|
System. |
The IFile that describes the file in the current IDirectory. |
Exceptions
Type | Condition |
---|---|
System. |
If a file with the same name exists in the target destination. |
System. |
If the source file can not be found. |
CopyFromAsync(FileInfo, Boolean, CancellationToken)
Copies a file asynchronously from an unmanaged System.
Declaration
Task<IFile> CopyFromAsync(FileInfo source, bool overwrite, CancellationToken cancellation = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
System. |
source | The System. |
System. |
overwrite | Overwrite the file if it already exists in this IDirectory |
System. |
cancellation | A cancellation token that is forwarded to the underlying System.Threading.Tasks.Task<TResult>. |
Returns
Type | Description |
---|---|
System. |
The IFile that describes the file in the current IDirectory. |
Exceptions
Type | Condition |
---|---|
System. |
If a file with the same name exists in the target destination and |
System. |
If the source file can not be found. |
CopyFromAsync(FileInfo, CancellationToken)
Copies a file asynchronously from an unmanaged System.
Declaration
Task<IFile> CopyFromAsync(FileInfo source, CancellationToken cancellation = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
System. |
source | The System. |
System. |
cancellation | A cancellation token that is forwarded to the underlying System.Threading.Tasks.Task<TResult>. |
Returns
Type | Description |
---|---|
System. |
The IFile that describes the file in the current IDirectory. |
Exceptions
Type | Condition |
---|---|
System. |
If a file with the same name exists in the target destination. |
System. |
If the source file can not be found. |
EnumerateDirectories()
Enumerates all direct child directories of this IDirectory.
Declaration
IEnumerable<IDirectory> EnumerateDirectories()
Returns
Type | Description |
---|---|
System. |
All direct children directories. |
EnumerateFiles()
Enumerates all files in this directory,
Declaration
IEnumerable<IFile> EnumerateFiles()
Returns
Type | Description |
---|---|
System. |
All direct children files. |
EnumerateFilesRecursive()
Recursively enumerates all files that are contained in this directory.
This method is usually implemented as a Breadth-first search, but no order is guaranteed.
Declaration
IEnumerable<IFile> EnumerateFilesRecursive()
Returns
Type | Description |
---|---|
System. |
All files contained within this directory, including descendant subfolders. |
LinkFrom(FileInfo)
Creates a link to an unmanaged System.
Links are transparent, i.e. Open
Links differ semantically from Files in two ways: Is
The underlying file that a link points to can only be modified through the stream.
Calling Delete() or Rename(String) will only rename
or delete the link. If the file the link points to does not exist,
calling Open
Links are very powerful and allow a way for plugins to escape the filesystem jail that an IDirectory
creates. Because they present the potential to modify files outside of the allocated directory, be very careful
when using them. Prefer read-only access by using As
Declaration
IFile LinkFrom(FileInfo source)
Parameters
Type | Name | Description |
---|---|---|
System. |
source | The System. |
Returns
Type | Description |
---|---|
IFile | The IFile that describes the file in the current IDirectory. |
Exceptions
Type | Condition |
---|---|
System. |
If a file with the same name exists in the target destination. |
System. |
If the source file can not be found. |
LinkFrom(FileInfo, Boolean)
Creates a link to an unmanaged System.
Links are transparent, i.e. Open
Links differ semantically from Files in two ways: Is
The underlying file that a link points to can only be modified through the stream.
Calling Delete() or Rename(String) will only rename
or delete the link. If the file the link points to does not exist,
calling Open
Links are very powerful and allow a way for plugins to escape the filesystem jail that an IDirectory
creates. Because they present the potential to modify files outside of the allocated directory, be very careful
when using them. Prefer read-only access by using As
Declaration
IFile LinkFrom(FileInfo source, bool overwrite)
Parameters
Type | Name | Description |
---|---|---|
System. |
source | The System. |
System. |
overwrite | Overwrite the file if it already exists in this IDirectory. The new link will inherit the GUID of the previously existing file. |
Returns
Type | Description |
---|---|
IFile | The IFile that describes the file in the current IDirectory. |
Exceptions
Type | Condition |
---|---|
System. |
If a file with the same name exists in the target destination and |
System. |
If the source file can not be found. |
MoveFrom(IFile)
Moves a file between IDirectory, updating the
manifests such that the resulting file has the same File
The source file will cease to exist in its original IDirectory.
There is no asychronous equivalent by design, since Move
Declaration
IFile MoveFrom(IFile source)
Parameters
Type | Name | Description |
---|---|---|
IFile | source | The System. |
Returns
Type | Description |
---|---|
IFile | The IFile that describes the file in the current IDirectory. |
Exceptions
Type | Condition |
---|---|
System. |
If a file with the same name exists in the target destination. |
System. |
If the source file can not be found. |
MoveFrom(IFile, Boolean)
Moves a file between IDirectory, updating the
manifests such that the resulting file has the same File
The source file will cease to exist in its original IDirectory.
There is no asychronous equivalent by design, since Move
Declaration
IFile MoveFrom(IFile source, bool overwrite)
Parameters
Type | Name | Description |
---|---|---|
IFile | source | The System. |
System. |
overwrite | Overwrite the file if it already exists in this IDirectory |
Returns
Type | Description |
---|---|
IFile | The IFile that describes the file in the current IDirectory. |
Exceptions
Type | Condition |
---|---|
System. |
If a file with the same name exists in the target destination and |
System. |
If the source file can not be found. |
OpenDirectory(String)
Opens an existing descendant directory with the given name. If the directory does not exist, creates the directory. You can open a nested directory using '/' as the path separator, and it will be created relative to this current directory.
Declaration
IDirectory OpenDirectory(string name)
Parameters
Type | Name | Description |
---|---|---|
System. |
name | The name of the existing directory |
Returns
Type | Description |
---|---|
IDirectory | The directory if it exists, or null if it does not. |
OpenFile(String)
Opens or creates a file, adding it to the manifest and assigning it a
unique System.
Unlike Open
Instead, use Open
Keep in mind this does not actually create a file on the underlying file system.
However, you can use Open
Declaration
IFile OpenFile(string file)
Parameters
Type | Name | Description |
---|---|---|
System. |
file | The name of the file. If this is a path, will be truncated with System. |
Returns
Type | Description |
---|---|
IFile | An object that associates a given file with a with a unique System. |
UnsafeGetPath()
Gets the underlying System.
This is very rarely necessary, and most IO tasks can be done efficiently and safely using the provided API. Manipulating the underlying file system will potentially desync the manifest, and cause loss of associated metadata.
Declaration
[Obsolete("Avoid accessing the underlying file path, and use the object methods instead.")]
DirectoryInfo UnsafeGetPath()
Returns
Type | Description |
---|---|
System. |
The underlying System. |