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.
- Listed in Other Alta assemblies
- Derived types
AltaFile,DatabaseSettingsFile,RemoteFiles.RemoteAltaFile<TFileType> - Documented in Settings and files
Properties
| Member | What 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
| Member | What 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:
ChunkFileHelper.GetFile, DynamicChunkContentManager.chunkFile, GlobalCommunalStorageValues.file, PlayerDataFileHelper<T>.GetAsync, PlayerDataFileHelper<T>.GetFileAsync, PlayerDataFileHelper<T>.GetSharedAsync, PlayerMapManager.file, PlayerMapManager.PlayerMapManager, ServerClientLandmarkManager.serverFile, BasicSaveFile<T>.ReadAndUnload, BasicSaveFile<T>.WriteAndUnload, ClientCacheManager.DownloadCache, ClientCacheManager.DownloaderFinished, ClientCacheManager.FileDownloader.completionSource, ClientCacheManager.FileDownloader.Finished, ClientCacheManager.FileDownloader.Task, AltaFolder.AllFiles, AltaFolder.FileExists, AltaFolder.files, AltaFolder.GetFile, AltaFolder.RemoveFile, IAltaFolder.AllFiles, IAltaFolder.FileExists, IAltaFolder.GetFile, IAltaFolder.RemoveFile, PlayerSaveUtility.Load, RemoteAltaFile.RemoteAltaFile, RemoteAltaFolder.FileExists, RemoteAltaFolder.GetFile, RemoteFiles.RemoteAltaFile<TFileType>.localFile, RemoteFiles.RemoteAltaFile<TFileType>.RemoteAltaFile<TFileType>, S3CloudStorageRemoteFile.S3CloudStorageRemoteFile, S3RemoteFolder.FileExists, S3RemoteFolder.GetFile, ServerSaveUtility.GetConfig, SettingsFileAccess<TSettings>.file, IPerPlayerContent<TSaveFormat>.LoadAsync, PerPlayerContent<TSaveFormat>.File, PerPlayerContent<TSaveFormat>.LoadAsync, Player.InitializePlayerOnServer, Player.saveFile, PlayerPostboxStorage.LoadAsync.