Skip to content

IFS

Namespace: Shadop.Archmage.Sdk

File system abstraction for Archmage configuration loading.

public interface IFS

Remarks:

When a file does not exist, IFS.ReadAllBytes(String) and IFS.ReadAllBytesAsync(String, CancellationToken) must throw FileNotFoundException. Archmage.LoadAtlas(String, String, IAtlas, AtlasOptions, IProgress) and Archmage.LoadAtlasAsync(String, String, IAtlas, AtlasOptions, Boolean, IProgress, CancellationToken) rely on this to skip missing override files.

If IFS.MainThreadOnly is true for the main IFS or for any override IFS, loading must start on the main thread. LoadAtlas and LoadAtlasAsync then call the methods of every IFS on the calling thread.

Otherwise, if MainThreadOnly is false for every IFS, LoadAtlas and LoadAtlasAsync read the files of atlas items with IFS.ReadAllBytes(String), and may call the methods on thread pool threads.

Gets whether the methods of this file system can be called only on the main thread.

public abstract bool MainThreadOnly { get; }

Boolean

Remarks:

Return true if the methods work only on the main thread, such as those that call Unity APIs. Return false if they can be called on any thread.

Reads all bytes from the specified file.

Byte[] ReadAllBytes(string path)

path String
The file path.

Byte[]
A byte array containing the contents of the file.

FileNotFoundException
The file does not exist.

ReadAllBytesAsync(String, CancellationToken)

Section titled “ReadAllBytesAsync(String, CancellationToken)”

Asynchronously reads all bytes from the specified file.

Task<Byte[]> ReadAllBytesAsync(string path, CancellationToken cancellationToken)

path String
The file path.

cancellationToken CancellationToken
The token to monitor for cancellation requests.

Task<Byte[]>
A task that represents the asynchronous read operation, wrapping the file contents as a byte array.

FileNotFoundException
The file does not exist.

Determines whether the specified file exists.

bool FileExists(string path)

path String
The file to check.

Boolean
true if the file exists or the check was skipped; otherwise, false.

Remarks:

If checking is expensive, an implementation may skip the check and return true.

Determines whether the specified directory exists.

bool DirectoryExists(string path)

path String
The directory to check.

Boolean
true if the directory exists or the check was skipped; otherwise, false.

Remarks:

If the storage has no directories, or checking is expensive, an implementation may skip the check and return true.