FlatImage
A configurable Linux containerization system
Loading...
Searching...
No Matches
casefold.hpp
Go to the documentation of this file.
1
8
9#pragma once
10
11#include <cstdint>
12#include <filesystem>
13
14#include "../std/expected.hpp"
15#include "../macro.hpp"
16#include "reserved.hpp"
17
28{
29
30namespace
31{
32
33namespace fs = std::filesystem;
34
35}
36
44inline Value<void> write(fs::path const& path_file_binary, uint8_t is_casefold)
45{
46 uint64_t offset_begin = ns_reserved::FIM_RESERVED_OFFSET_CASEFOLD_BEGIN;
47 uint64_t offset_end = ns_reserved::FIM_RESERVED_OFFSET_CASEFOLD_END;
48 uint64_t size = offset_end - offset_begin;
49 return_if(size != sizeof(uint8_t)
50 , Error("E::Incorrect number of bytes to write notification flag: {} vs {}", size, sizeof(uint8_t))
51 );
52 return ns_reserved::write(path_file_binary, offset_begin, offset_end, reinterpret_cast<char*>(&is_casefold), sizeof(uint8_t));
53}
54
61inline Value<uint8_t> read(fs::path const& path_file_binary)
62{
63 uint64_t offset_begin = ns_reserved::FIM_RESERVED_OFFSET_CASEFOLD_BEGIN;
64 uint8_t is_casefold;
65 ssize_t bytes = Pop(ns_reserved::read(path_file_binary, offset_begin, reinterpret_cast<char*>(&is_casefold), sizeof(uint8_t)));
66 return_if(bytes != 1, Error("E::Error to read notify byte, count is {}", bytes));
67 return is_casefold;
68}
69
70} // namespace ns_reserved::ns_casefold
71
72/* vim: set expandtab fdm=marker ts=2 sw=2 tw=100 et :*/
Enhanced error handling framework built on std::expected.
Simplified macros for common control flow patterns with optional logging.
Case-insensitive filesystem flag management in reserved space.
Value< uint8_t > read(fs::path const &path_file_binary)
Read a notification flag from the flatimage binary.
Definition casefold.hpp:61
Value< void > write(fs::path const &path_file_binary, uint8_t is_casefold)
Writes a notification flag to the flatimage binary.
Definition casefold.hpp:44
Value< void > write(fs::path const &path_file_binary, uint64_t offset_begin, uint64_t offset_end, const char *data, uint64_t length) noexcept
Writes data to a file in binary format.
Definition reserved.hpp:142
Value< std::streamsize > read(fs::path const &path_file_binary, uint64_t offset, char *data, uint64_t length) noexcept
Reads data from a file in binary format.
Definition reserved.hpp:172
Manages reserved space.
Enhanced expected type with integrated logging capabilities.
Definition expected.hpp:44