Loading...
Searching...
No Matches
map_storage.h
Go to the documentation of this file.
89inline std::string fileDigest(const std::filesystem::path& path, const std::function<bool()>& stopped = {}) {
93 if (input.get() < 0 || fstat(input.get(), &before) != 0 || !S_ISREG(before.st_mode) || before.st_size < 0)
100 const auto count = read(input.get(), buffer.data(), std::min<std::uint64_t>(remaining, buffer.size()));
108 before.st_mtim.tv_sec != after.st_mtim.tv_sec || before.st_mtim.tv_nsec != after.st_mtim.tv_nsec ||
124 if (bytes > UINT64_MAX - reserve || statvfs(directory.c_str(), &status) != 0 || !status.f_frsize ||
135inline void publishWorkingFile(const std::filesystem::path& temporary, const std::filesystem::path& target,
137 StorageDescriptor descriptor(open(temporary.c_str(), O_RDONLY | O_NONBLOCK | O_CLOEXEC | O_NOFOLLOW));
139 if (descriptor.get() < 0 || fstat(descriptor.get(), &completed) != 0 || !S_ISREG(completed.st_mode))
cv::Mat read(const cv::Rect &rectangle) const
Read a rectangle into a new BGRA matrix.
Definition map_storage.h:209
DiskRaster(std::filesystem::path path, int width, int height)
Open a raster whose byte length must match its declared dimensions.
Definition map_storage.h:197
Own a working-file descriptor through success and exception paths.
Definition map_storage.h:45
~StorageDescriptor()
Close an owned descriptor; use close() when the status matters.
Definition map_storage.h:56
void reset(int descriptor)
Relinquish the old descriptor and adopt a distinct replacement.
Definition map_storage.h:63
StorageDescriptor(const StorageDescriptor &)=delete
Noncopyable: ownership cannot be shared by copying the FD number.
StorageDescriptor & operator=(const StorageDescriptor &)=delete
Nonassignable: use reset() to replace the owned descriptor.
StorageDescriptor(int descriptor=-1)
Adopt a descriptor without duplicating it.
Definition map_storage.h:50
Definition camera_optics.h:32
void storageHeadroom(const std::filesystem::path &directory, std::uint64_t bytes)
Require requested free space plus a fixed safety reserve.
Definition map_storage.h:121
std::string fileDigest(const std::filesystem::path &path, const std::function< bool()> &stopped={})
Hash a file in bounded chunks, optionally honoring cancellation.
Definition map_storage.h:89
void publishWorkingFile(const std::filesystem::path &temporary, const std::filesystem::path &target, bool replace=true)
Fsync a completed working file, rename it, then sync its directory.
Definition map_storage.h:135
std::string dataDigest(const void *data, std::size_t size)
Compute a lowercase SHA-256 digest for an in-memory byte range.
Definition map_storage.h:77
void saveWorkingText(const std::filesystem::path &target, const std::string &text)
Save checkpoint text through the durable working-file publisher.
Definition map_storage.h:158
void sha256_hex(const void *data, size_t length, char *output)
Hash one memory region to a lowercase hexadecimal string.
Definition sha256fst.c:272
void sha256_finalize_hex(struct sha256 *context, char *output)
Finish a message and write its lowercase hexadecimal digest.
Definition sha256fst.c:249
void sha256_append(struct sha256 *context, const void *data, size_t length)
Append an arbitrarily aligned chunk; empty chunks are harmless.
Definition sha256fst.c:190
void sha256_init(struct sha256 *context)
Initialize or reset a context for a new message.
Definition sha256fst.c:168
Allocation-free, portable SHA-256 checksums for memory and streams.