coastline 0.0.4
Loading...
Searching...
No Matches
coastline::ControllerPak Class Reference

The notes of a Controller Pak, stored in a directory, with the settings note in another. More...

#include <controllerpak.h>

Public Member Functions

 ControllerPak (std::filesystem::path directory, std::filesystem::path settingsDirectory={})
 Select note directories without creating or reading them.
std::optional< std::vector< std::uint8_t > > ReadNote (const std::string &name, const SavePayloadValidator &validate={}) const
 Validate the note's integrity header and checksum, attempting to delete corrupt saves.
bool WriteNote (const std::string &name, std::span< const std::uint8_t > bytes) const
 Atomically write a complete note with its integrity header and checksum.
bool DeleteNote (const std::string &name) const
std::vector< PakNote > Notes () const
std::size_t FreeBytes () const
ControllerPak Subdirectory (const std::filesystem::path &directory) const
 Store independent notes beneath the Controller Pak directory without using its capacity.

Detailed Description

The notes of a Controller Pak, stored in a directory, with the settings note in another.

Constructor & Destructor Documentation

◆ ControllerPak()

coastline::ControllerPak::ControllerPak ( std::filesystem::path directory,
std::filesystem::path settingsDirectory = {} )
explicit

Select note directories without creating or reading them.

Parameters
directoryThe directory of the notes, created at the first write.
settingsDirectoryThe directory of PAK_SETTINGS_NOTE, or empty for the directory of the other notes.

Member Function Documentation

◆ ReadNote()

std::optional< std::vector< std::uint8_t > > coastline::ControllerPak::ReadNote ( const std::string & name,
const SavePayloadValidator & validate = {} ) const

Validate the note's integrity header and checksum, attempting to delete corrupt saves.

Parameters
nameAn ASCII note filename without path separators or reserved metadata names.
validateOptional semantic validator; rejection attempts deletion under the note lock.
Returns
Native note bytes, or an empty optional when missing, unreadable, or rejected.

◆ WriteNote()

bool coastline::ControllerPak::WriteNote ( const std::string & name,
std::span< const std::uint8_t > bytes ) const

Atomically write a complete note with its integrity header and checksum.

Parameters
nameAn ASCII note filename without path separators or reserved metadata names.
bytesNon-empty native note bytes, at most PAK_IMAGE_BYTES.
Returns
Whether the note was written.

◆ DeleteNote()

bool coastline::ControllerPak::DeleteNote ( const std::string & name) const
Parameters
nameAn ASCII note filename without path separators or reserved metadata names.
Returns
Whether the note was deleted.

◆ Notes()

std::vector< PakNote > coastline::ControllerPak::Notes ( ) const
Returns
The notes of the pak, in the order of their names.

◆ FreeBytes()

std::size_t coastline::ControllerPak::FreeBytes ( ) const
Returns
The bytes of the pages no note takes, as osPfsFreeBlocks() counts them.

◆ Subdirectory()

ControllerPak coastline::ControllerPak::Subdirectory ( const std::filesystem::path & directory) const

Store independent notes beneath the Controller Pak directory without using its capacity.

Parameters
directoryA relative child directory for notes excluded from the parent inventory.
Returns
A pak whose notes and settings both use the child directory.

The documentation for this class was generated from the following file: