|
coastline 0.0.4
|
An exclusive lock shared by cooperating save writers, released on destruction or process exit. More...
#include <savefile.h>
Public Member Functions | |
| ~SaveFile () | |
| Release the process lock and its native handle. | |
| SaveFile (SaveFile &&) noexcept | |
| Transfer the source save's process lock without releasing it. | |
| SaveFile & | operator= (SaveFile &&) noexcept |
| Release the destination lock and transfer the source save's process lock. | |
| std::optional< std::vector< std::uint8_t > > | Read (std::size_t limit) const |
| Read the locked save with bounded allocation. | |
| bool | Write (std::span< const std::uint8_t > bytes) const |
| Replace the save atomically after writing and synchronising a unique sibling file. | |
| bool | Remove () const |
| Delete the locked save while excluding cooperating writers. | |
Static Public Member Functions | |
| static std::optional< SaveFile > | Open (const std::filesystem::path &path) |
| Lock a save for a complete read-modify-write transaction, creating parent directories. | |
An exclusive lock shared by cooperating save writers, released on destruction or process exit.
| coastline::SaveFile::~SaveFile | ( | ) |
Release the process lock and its native handle.
|
noexcept |
Transfer the source save's process lock without releasing it.
|
static |
Lock a save for a complete read-modify-write transaction, creating parent directories.
| path | Destination file. A persistent sibling lock file coordinates other writers. |
Release the destination lock and transfer the source save's process lock.
| std::optional< std::vector< std::uint8_t > > coastline::SaveFile::Read | ( | std::size_t | limit | ) | const |
Read the locked save with bounded allocation.
| limit | Maximum accepted length in bytes. |
| bool coastline::SaveFile::Write | ( | std::span< const std::uint8_t > | bytes | ) | const |
Replace the save atomically after writing and synchronising a unique sibling file.
| bytes | Complete new contents. |
| bool coastline::SaveFile::Remove | ( | ) | const |
Delete the locked save while excluding cooperating writers.