/** * Copyright (c) 2026 Dominic Masters * * This software is released under the MIT License. * https://opensource.org/licenses/MIT */ #pragma once #include "error/error.h" #include "save/saveslot.h" #include "save/savemeta.h" #define SAVE_LINUX_PATH_MAX FILENAME_MAX #define SAVE_LINUX_SLOT_FILE_FORMAT "%s/slot%u.json" #define SAVE_LINUX_META_FILE_FORMAT "%s/settings.json" #ifndef SAVE_LINUX_PATH #define SAVE_LINUX_PATH "./saves" #endif typedef struct { char_t savePath[SAVE_LINUX_PATH_MAX]; } savelinux_t; /** * Initializes the save system on Linux - ensures the save directory * exists (shared by both save slots and meta). * * @return An error code if initialization fails. */ errorret_t saveInitLinux(void); /** * Disposes of the save system on Linux. * * @return An error code if disposal fails. */ errorret_t saveDisposeLinux(void); /** * Loads a save slot as JSON (slotN.json) from disk, if it exists. * * @param slot The save slot index. * @param out Output slot data. * @return An error code if the slot exists but fails to parse. */ errorret_t saveSlotLoadLinux(const uint8_t slot, saveslot_t *out); /** * Writes a save slot as JSON (slotN.json) to disk. * * @param slot The save slot index. * @param slotData Slot data to write. * @return An error code if the write fails. */ errorret_t saveSlotWriteLinux(const uint8_t slot, saveslot_t *slotData); /** * Deletes the save slot JSON file for the given index. * * @param slot The save slot index. * @return An error code if the delete fails. */ errorret_t saveDeleteSlotLinux(const uint8_t slot); /** * Loads save meta as JSON (settings.json) from disk, if it exists. * * @param out Output meta data. * @return An error code if the file exists but fails to parse. */ errorret_t saveMetaLoadLinux(savemeta_t *out); /** * Writes save meta as JSON (settings.json) to disk. * * @param meta Meta data to write. * @return An error code if the write fails. */ errorret_t saveMetaWriteLinux(savemeta_t *meta);