OpenSWMM Engine  6.0.0-alpha.4
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.4)
Loading...
Searching...
No Matches
CheckpointFile.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: Apache-2.0
2
11
12#pragma once
13#include <filesystem>
14#include <memory>
15#include <string>
16#include <cstdint>
17#include <cstdio>
18
19namespace openswmm::io {
23 std::filesystem::path path;
24 uint64_t bytes = 0, fingerprint = 0;
31 std::string encode() const;
41 static CheckpointFile decode(std::string);
50 void verify() const; // fixed 64 KiB read buffer
51};
54 bool owned = true;
66 void retain() noexcept { owned = false; }
67};
68
72
90std::shared_ptr<OwnedCheckpointFile> copyCheckpointFile(const std::filesystem::path& source,
91 uint64_t bytes,
92 const std::filesystem::path& staging_base,
93 int source_descriptor = -1);
101uint64_t checkpointFileSize(const std::filesystem::path& path);
110void checkpointSeek(FILE* f, uint64_t offset);
111}
Definition AtomicOutputFile.hpp:25
void checkpointSeek(FILE *f, uint64_t offset)
Position an existing stream at an absolute checkpoint byte offset.
Definition CheckpointFile.cpp:109
uint64_t checkpointFileSize(const std::filesystem::path &path)
Read a checkpoint companion's validated size.
Definition CheckpointFile.cpp:101
std::shared_ptr< OwnedCheckpointFile > copyCheckpointFile(const std::filesystem::path &source, uint64_t bytes, const std::filesystem::path &base, int source_descriptor)
Copy and verify an exact source prefix into a private companion file.
Definition CheckpointFile.cpp:158
Definition CheckpointFile.hpp:22
uint64_t bytes
Definition CheckpointFile.hpp:24
static CheckpointFile decode(std::string)
Decode and validate a versioned companion-file contract.
Definition CheckpointFile.cpp:128
std::filesystem::path path
Definition CheckpointFile.hpp:23
std::string encode() const
Serialize this companion's path, length and fingerprint contract.
Definition CheckpointFile.cpp:119
uint64_t fingerprint
Definition CheckpointFile.hpp:24
void verify() const
Check the named companion's exact size and fingerprint.
Definition CheckpointFile.cpp:144
Definition CheckpointFile.hpp:52
~OwnedCheckpointFile()
Remove file.path when this owner has not called retain().
Definition CheckpointFile.cpp:151
CheckpointFile file
Definition CheckpointFile.hpp:53
bool owned
Definition CheckpointFile.hpp:54
void retain() noexcept
Release automatic removal responsibility for the companion file.
Definition CheckpointFile.hpp:66