updated build system
All checks were successful
BlockStorage/repertory/pipeline/head This commit looks good

This commit is contained in:
2024-10-20 12:01:23 -05:00
parent 104e101158
commit 1f6036ec18
17 changed files with 696 additions and 705 deletions

View File

@@ -115,11 +115,10 @@ void file::open() {
REPERTORY_USES_FUNCTION_NAME();
if (not is_file(path_)) {
throw utils::error::create_exception({
function_name,
"file not found",
path_,
});
throw utils::error::create_exception(function_name, {
"file not found",
path_,
});
}
#if defined(_WIN32)
@@ -300,20 +299,20 @@ auto file::read(unsigned char *data, std::size_t to_read, std::uint64_t offset,
try {
if (not file_) {
throw utils::error::create_exception({
function_name,
"file is not open for reading",
path_,
});
throw utils::error::create_exception(function_name,
{
"file is not open for reading",
path_,
});
}
if (fseeko(file_.get(), static_cast<std::int64_t>(offset), SEEK_SET) ==
-1) {
throw utils::error::create_exception({
function_name,
"failed to seek before read",
path_,
});
throw utils::error::create_exception(function_name,
{
"failed to seek before read",
path_,
});
}
std::size_t bytes_read{0U};
@@ -321,11 +320,11 @@ auto file::read(unsigned char *data, std::size_t to_read, std::uint64_t offset,
auto res =
fread(&data[bytes_read], 1U, to_read - bytes_read, file_.get());
if (not feof(file_.get()) && ferror(file_.get())) {
throw utils::error::create_exception({
function_name,
"failed to read file bytes",
path_,
});
throw utils::error::create_exception(function_name,
{
"failed to read file bytes",
path_,
});
}
if (res == 0) {
@@ -367,12 +366,12 @@ auto file::sha256() -> std::optional<std::string> {
crypto_hash_sha256_state state{};
auto res = crypto_hash_sha256_init(&state);
if (res != 0) {
throw utils::error::create_exception({
function_name,
"failed to initialize sha256",
std::to_string(res),
path_,
});
throw utils::error::create_exception(function_name,
{
"failed to initialize sha256",
std::to_string(res),
path_,
});
}
{
@@ -389,12 +388,12 @@ auto file::sha256() -> std::optional<std::string> {
&state, reinterpret_cast<const unsigned char *>(buffer.data()),
bytes_read);
if (res != 0) {
throw utils::error::create_exception({
function_name,
"failed to update sha256",
std::to_string(res),
path_,
});
throw utils::error::create_exception(function_name,
{
"failed to update sha256",
std::to_string(res),
path_,
});
}
}
}
@@ -402,12 +401,12 @@ auto file::sha256() -> std::optional<std::string> {
std::array<unsigned char, crypto_hash_sha256_BYTES> out{};
res = crypto_hash_sha256_final(&state, out.data());
if (res != 0) {
throw utils::error::create_exception({
function_name,
"failed to finalize sha256",
std::to_string(res),
path_,
});
throw utils::error::create_exception(function_name,
{
"failed to finalize sha256",
std::to_string(res),
path_,
});
}
ret = utils::collection::to_hex_string(out);
@@ -497,20 +496,20 @@ auto file::write(const unsigned char *data, std::size_t to_write,
try {
if (not file_) {
throw utils::error::create_exception({
function_name,
"file is not open for writing",
path_,
});
throw utils::error::create_exception(function_name,
{
"file is not open for writing",
path_,
});
}
auto res = fseeko(file_.get(), static_cast<std::int64_t>(offset), SEEK_SET);
if (res == -1) {
throw utils::error::create_exception({
function_name,
"failed to seek before write",
path_,
});
throw utils::error::create_exception(function_name,
{
"failed to seek before write",
path_,
});
}
std::size_t bytes_written{0U};
@@ -519,11 +518,11 @@ auto file::write(const unsigned char *data, std::size_t to_write,
fwrite(reinterpret_cast<const char *>(&data[bytes_written]), 1U,
to_write - bytes_written, file_.get());
if (not feof(file_.get()) && ferror(file_.get())) {
throw utils::error::create_exception({
function_name,
"failed to write file bytes",
path_,
});
throw utils::error::create_exception(function_name,
{
"failed to write file bytes",
path_,
});
}
if (written == 0U) {
@@ -555,20 +554,20 @@ auto file::size() const -> std::optional<std::uint64_t> {
try {
if (file_) {
if (fseeko(file_.get(), 0, SEEK_END) == -1) {
throw utils::error::create_exception({
function_name,
"failed to seek",
path_,
});
throw utils::error::create_exception(function_name,
{
"failed to seek",
path_,
});
}
auto size = ftello(file_.get());
if (size == -1) {
throw utils::error::create_exception({
function_name,
"failed to get position",
path_,
});
throw utils::error::create_exception(function_name,
{
"failed to get position",
path_,
});
}
return static_cast<std::uint64_t>(size);
@@ -576,11 +575,11 @@ auto file::size() const -> std::optional<std::uint64_t> {
std::uint64_t size{};
if (not get_file_size(path_, size)) {
throw utils::error::create_exception({
function_name,
"failed to get file size",
path_,
});
throw utils::error::create_exception(function_name,
{
"failed to get file size",
path_,
});
}
return size;