Godot storage paths
Use res:// for bundled files and user:// for settings, progress, and backups. GodotFileStorage reads res:// through Godot's file API, including files shipped in a PCK. Include raw JSON files in the export preset. Writes and deletes targeting res:// throw NotSupportedException; save snapshots also reject resource paths.
Save existing JSON
Pass the same ISerializer your game already uses, with the same naming rules, converters, and other JSON settings. Create and retain the storage in the composition root.
using GFramework.Godot.Storage;
using var storage = new GodotFileStorage(gameSerializer);When the settings screen saves the edited volume, write the existing settings DTO through that shared instance.
await storage.WriteAsync("user://settings/player.json", settings);If your game already produced a complete JSON string, encode it as UTF-8 and write those bytes through the snapshot API. Passing that string to a JSON serializer would encode it as a JSON string value. If you already have the original file bytes, pass them directly to StorageSnapshot.
using System.Text;
using GFramework.Game.Abstractions.Storage;
await storage.WriteSnapshotAsync(
"user://settings/player.json",
new StorageSnapshot(Encoding.UTF8.GetBytes(json)));Call file operations for user:// from the Godot thread so the adapter can resolve the physical path before awaiting. Reuse a storage instance for ongoing reads and writes so operations on the same key share its lock. Once the full JSON has been written to a sibling temporary file, the storage replaces the destination in one operation. It preserves the chosen filename and creates parent directories on write. Atomic replacement applies to one file and does not guarantee durability after power loss.
A missing player file or parent directory gives false from ExistsAsync, FileNotFoundException from ReadAsync, and a successful no-op from DeleteAsync. Read(key, fallback) uses the fallback for a missing file. Access failures and invalid JSON surface to the caller. For a backup that preserves the exact bytes, use ReadSnapshotAsync and WriteSnapshotAsync. Use the versioned save repository for save slots and migrations.