Class JsonEnvelopeFile
- Namespace
- SurvivorsMaker.Presentation
- Assembly
- SurvivorsMaker.Presentation.dll
One save domain (options, profile or run) in one JSON file, written as a SaveEnvelope with JsonUtility and read through Read(SaveEnvelope, SaveDomain).
- Writes go to a temporary file that is read back and then swapped in with Replace(string, string, string) (a plain copy only where the platform has no replace).
- A corrupt or incompatible file is moved aside (
*.corrupt/*.incompatible) and kept; the store then starts from defaults. - A file from a newer schema, or an unreadable file, is left untouched and the store refuses to write over it for the rest of the session.
public sealed class JsonEnvelopeFile
- Inheritance
-
JsonEnvelopeFile
- Inherited Members
Constructors
JsonEnvelopeFile(string, SaveDomain)
public JsonEnvelopeFile(string path, SaveDomain domain)
Parameters
pathstringdomainSaveDomain
Fields
CorruptSuffix
public const string CorruptSuffix = ".corrupt"
Field Value
IncompatibleSuffix
public const string IncompatibleSuffix = ".incompatible"
Field Value
TemporarySuffix
public const string TemporarySuffix = ".tmp"
Field Value
Properties
Domain
public SaveDomain Domain { get; }
Property Value
HasRead
public bool HasRead { get; }
Property Value
LastRead
Result of the last read (Missing before the first one).
public SaveReadResult LastRead { get; }
Property Value
Path
public string Path { get; }
Property Value
PreservedPath
Where a corrupt or incompatible file was moved, or empty.
public string PreservedPath { get; }
Property Value
WriteBlocked
True when the file on disk must be preserved as it is (newer schema, unreadable).
public bool WriteBlocked { get; }
Property Value
Methods
Delete(bool)
Removes the file (an empty run slot). Blocked files are kept unless force (an explicit reset).
public bool Delete(bool force = false)
Parameters
forcebool
Returns
Read(SaveMigrationRegistry)
Reads, validates and migrates the file. Never throws for file or data problems.
public SaveReadResult Read(SaveMigrationRegistry migrations)
Parameters
migrationsSaveMigrationRegistry
Returns
Write(SaveEnvelope, SaveMigrationRegistry)
Writes envelope as the next generation. False when blocked or the write failed.
public bool Write(SaveEnvelope envelope, SaveMigrationRegistry migrationsForFirstRead)
Parameters
envelopeSaveEnvelopemigrationsForFirstReadSaveMigrationRegistry