Skip to main content

IAltaFile

An interface in Alta.IO, Alta.Utilities.

A file in the game's save and settings storage, with async reads into a typed format and safe writes. AltaFile is the disk version: it writes to a temp file, then swaps it in and keeps the old one as a _backup copy.

Properties​

MemberWhat it is
IAltaFileFormat Content { get; set; }The loaded content. Setting a new value disposes the old one.
string FullName { get; }Full path on disk.
bool HasChanged { get; }Set to true after a write completes. Cleared with ResetHasChanged.
bool IsExisting { get; }True if the file exists on disk.
bool IsReading { get; }True while a read is running.
bool IsWriting { get; }True while a write is running.
string Name { get; }File name with extension.

Methods​

MemberWhat it is
void Delete(bool isDeletingBackup = false)Deletes the file from disk and its folder, and drops the content. Can also delete the backup.
Task DeleteAsync(bool isDeletingBackup = false)Same as Delete, but the disk work runs on a background task.
void FinishReading()Blocks until any running read finishes.
void FinishWriting()Blocks until any running write finishes.
void MoveTo(IAltaFolder folder)Moves the file, and its backup if there is one, into another folder.
void QueueUnload()Drops the loaded content now, or after the current write finishes. Refused while reading.
Task QueueUnloadAsync()Like QueueUnload, but waits for the current write when there is one.
Task<T> ReadAsync<T>()Reads the file into the given format on a background task, or returns the content if already loaded. Content is null if the file is missing.
Task<T> ReadAsync<T>(Func<T> create)Reads the file into the given format on a background task, or returns the content if already loaded. Content is null if the file is missing.
void Refresh()Refreshes the cached file info from disk.
void ResetHasChanged()Clears HasChanged.
void WriteAsync()Writes a copy of the current content on a background task. A newer write cancels one still running.

Used in​

Members of other types that take, return or hold a IAltaFile: