Interface IReliableFileStorage
Service to interact with the file system, as a replacement for standard C# file I/O. Writes and reads using this service are, to the best of our ability, atomic and reliable.
All data is synced to disk immediately and written to a database, additionally to files on disk. This means that in case of file corruption, data can likely be recovered from the database.
However, this also means that operations using this service duplicate data on disk, so we don't recommend performing large file operations. The service will not permit files larger than Dalamud.Plugin.Services.IReliableFileStorage.MaxFileSizeBytes (64MB) to be written.
Saved configuration data using the Dalamud.Configuration.PluginConfigurations class uses this functionality implicitly.
Assembly: Dalamud.dll
[Experimental("Dalamud001")]
public interface IReliableFileStorage : IDalamudService
Properties
MaxFileSizeBytes
Gets the maximum file size, in bytes, that can be written using this service.
long MaxFileSizeBytes { get; }
Methods
Exists(string)
Check whether a file exists either on the local filesystem or in the transparent backup database.
bool Exists(string path)
Returns
System.Boolean: True if the file exists on disk or a backup copy exists in the storage's internal journal/backup database;
otherwise false.
Parameters
| Type | Name | Description |
|---|---|---|
System.String | path | The file system path to check. Must not be null or empty. |
Exceptions
System.ArgumentException
Thrown when <code class="paramref">path</code> is null or empty.
WriteAllTextAsync(string, string?)
Write the given text into a file using UTF-8 encoding. The write is performed atomically and is persisted to both the filesystem and the internal backup database used by this service.
Task WriteAllTextAsync(string path, string? contents)
Returns
System.Threading.Tasks.Task: A System.Threading.Tasks.Task that completes when the write has finished and been flushed to disk and the backup.
Parameters
| Type | Name | Description |
|---|---|---|
System.String | path | The file path to write to. Must not be null or empty. |
System.String | contents | The string contents to write. May be null, in which case an empty file is written. |