IFS
Namespace: Shadop.Archmage.Sdk
File system abstraction for Archmage configuration loading.
public interface IFSRemarks:
When a file does not exist, IFS.ReadAllBytes(String) and IFS.ReadAllBytesAsync(String, CancellationToken)
must throw FileNotFoundException. Archmage.LoadAtlas(String, String, IAtlas, AtlasOptions, IProgress
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.
Properties
Section titled “Properties”MainThreadOnly
Section titled “MainThreadOnly”Gets whether the methods of this file system can be called only on the main thread.
public abstract bool MainThreadOnly { get; }Property Value
Section titled “Property Value”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.
Methods
Section titled “Methods”ReadAllBytes(String)
Section titled “ReadAllBytes(String)”Reads all bytes from the specified file.
Byte[] ReadAllBytes(string path)Parameters
Section titled “Parameters”path String
The file path.
Returns
Section titled “Returns”Byte[]
A byte array containing the contents of the file.
Exceptions
Section titled “Exceptions”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)Parameters
Section titled “Parameters”path String
The file path.
cancellationToken CancellationToken
The token to monitor for cancellation requests.
Returns
Section titled “Returns”Task<Byte[]>
A task that represents the asynchronous read operation, wrapping the file contents as a byte array.
Exceptions
Section titled “Exceptions”FileNotFoundException
The file does not exist.
FileExists(String)
Section titled “FileExists(String)”Determines whether the specified file exists.
bool FileExists(string path)Parameters
Section titled “Parameters”path String
The file to check.
Returns
Section titled “Returns”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.
DirectoryExists(String)
Section titled “DirectoryExists(String)”Determines whether the specified directory exists.
bool DirectoryExists(string path)Parameters
Section titled “Parameters”path String
The directory to check.
Returns
Section titled “Returns”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.