IO

spec.IO (Interface) → backend.IO

Backend interface for file input/output operations.

This interface provides simple key-value file storage in the platform's storage directory. It's primarily used for saving game data, preferences, and other persistent information.

The 'key' parameter is typically a relative file path within the storage directory. Backends handle the actual file system operations and ensure data is written to the appropriate platform-specific location.

See: spec.Info.storageDirectory() for the storage location

Instance Members

saveString(key: String, str: String): Bool

Saves a string to persistent storage, overwriting any existing content. The key is used as a relative file path within the storage directory.

Name Type Description
key String The storage key/path (e.g., "saves/game1.json")
str String The string content to save
Returns Description
Bool True if the save was successful, false on error

appendString(key: String, str: String): Bool

Appends a string to an existing file in persistent storage. If the file doesn't exist, it will be created.

Name Type Description
key String The storage key/path (e.g., "logs/debug.txt")
str String The string content to append
Returns Description
Bool True if the append was successful, false on error

readString(key: String): String

Reads a string from persistent storage.

Name Type Description
key String The storage key/path (e.g., "saves/game1.json")
Returns Description
String The file contents as a string, or null if the file doesn't exist or can't be read