summaryrefslogtreecommitdiff
path: root/include/fud_c_file.hpp
diff options
context:
space:
mode:
authorDominick Allen <djallen@librehumanitas.org>2024-10-30 09:51:54 -0500
committerDominick Allen <djallen@librehumanitas.org>2024-10-30 09:51:54 -0500
commit6c7fd1db481ff10a16ecab958c6542784fa60b9c (patch)
treee0162f930ec44a7c53b07061311d52910c36e481 /include/fud_c_file.hpp
parent8dcb1de91e15ff7fc66279cd9cd9ad8a70f624e0 (diff)
Use std::byte* instead of void* for allocators.
Diffstat (limited to 'include/fud_c_file.hpp')
-rw-r--r--include/fud_c_file.hpp40
1 files changed, 20 insertions, 20 deletions
diff --git a/include/fud_c_file.hpp b/include/fud_c_file.hpp
index bf148c2..e0be680 100644
--- a/include/fud_c_file.hpp
+++ b/include/fud_c_file.hpp
@@ -18,11 +18,11 @@
#ifndef FUD_C_FILE_HPP
#define FUD_C_FILE_HPP
+#include "fud_drain.hpp"
#include "fud_permissions.hpp"
#include "fud_result.hpp"
#include "fud_status.hpp"
#include "fud_string.hpp"
-#include "fud_file.hpp"
#include <cstdint>
#include <cstdio>
@@ -184,16 +184,16 @@ class CFile {
return RetType::okay(fileSize);
}
- [[nodiscard]] ReadResult read(void* destination, size_t destinationSize, size_t length)
+ [[nodiscard]] DrainResult read(void* destination, size_t destinationSize, size_t length)
{
auto& self = static_cast<Derived&>(*this);
return self.read(destination, destinationSize, length, 0);
}
- [[nodiscard]] ReadResult read(void* destination, size_t destinationSize, size_t length, size_t offset)
+ [[nodiscard]] DrainResult read(void* destination, size_t destinationSize, size_t length, size_t offset)
{
auto& self = static_cast<Derived&>(*this);
- ReadResult result{};
+ DrainResult result{};
if (length == 0) {
return result;
}
@@ -227,9 +227,9 @@ class CFile {
}
auto* destBytes = static_cast<char*>(destination);
- result.bytesRead = fread(destBytes, 1, length, self.m_file);
+ result.bytesDrained = fread(destBytes, 1, length, self.m_file);
static_cast<void>(self.reset());
- if (result.bytesRead != length) {
+ if (result.bytesDrained != length) {
result.status = FudStatus::Partial;
} else {
result.status = FudStatus::Success;
@@ -239,7 +239,7 @@ class CFile {
}
template <typename T>
- [[nodiscard]] ReadResult read(T& destination, size_t length)
+ [[nodiscard]] DrainResult read(T& destination, size_t length)
{
static_assert(not std::is_pointer_v<decltype(destination)>);
auto& self = static_cast<Derived&>(*this);
@@ -247,39 +247,39 @@ class CFile {
}
template <typename T>
- [[nodiscard]] ReadResult read(T& destination, size_t length, size_t offset)
+ [[nodiscard]] DrainResult read(T& destination, size_t length, size_t offset)
{
static_assert(not std::is_pointer_v<decltype(destination)>);
auto& self = static_cast<Derived&>(*this);
return self.read(&destination, sizeof(destination), length, offset);
}
- [[nodiscard]] WriteResult write(const void* source, size_t sourceSize)
+ [[nodiscard]] DrainResult write(const void* source, size_t sourceSize)
{
auto& self = static_cast<Derived&>(*this);
auto offsetResult = self.size();
if (offsetResult.isError()) {
- return WriteResult{0, offsetResult.getError()};
+ return DrainResult{0, offsetResult.getError()};
}
return self.write(source, sourceSize, sourceSize, offsetResult.getOkay());
}
- [[nodiscard]] WriteResult write(const void* source, size_t sourceSize, size_t length)
+ [[nodiscard]] DrainResult write(const void* source, size_t sourceSize, size_t length)
{
auto& self = static_cast<Derived&>(*this);
auto offsetResult = self.size();
if (offsetResult.isError()) {
- return WriteResult{0, offsetResult.getError()};
+ return DrainResult{0, offsetResult.getError()};
}
return self.write(source, sourceSize, length, offsetResult.getOkay());
}
- [[nodiscard]] WriteResult write(const void* source, size_t sourceSize, size_t length, size_t offset)
+ [[nodiscard]] DrainResult write(const void* source, size_t sourceSize, size_t length, size_t offset)
{
auto& self = static_cast<Derived&>(*this);
- WriteResult result{};
+ DrainResult result{};
if (length == 0) {
return result;
}
@@ -315,9 +315,9 @@ class CFile {
}
const auto* sourceBytes = static_cast<const char*>(source);
- result.bytesWritten = fwrite(sourceBytes, 1, length, self.m_file);
+ result.bytesDrained = fwrite(sourceBytes, 1, length, self.m_file);
static_cast<void>(self.reset());
- if (result.bytesWritten != length) {
+ if (result.bytesDrained != length) {
result.status = FudStatus::Partial;
} else {
result.status = FudStatus::Success;
@@ -327,7 +327,7 @@ class CFile {
}
template <typename T>
- [[nodiscard]] WriteResult write(const T& source)
+ [[nodiscard]] DrainResult write(const T& source)
{
static_assert(not std::is_pointer_v<decltype(source)>);
auto& self = static_cast<Derived&>(*this);
@@ -335,19 +335,19 @@ class CFile {
}
template <typename T>
- [[nodiscard]] WriteResult write(const T& source, size_t sourceSize, size_t length)
+ [[nodiscard]] DrainResult write(const T& source, size_t sourceSize, size_t length)
{
static_assert(not std::is_pointer_v<decltype(source)>);
auto& self = static_cast<Derived&>(*this);
auto offsetResult = self.size();
if (offsetResult.isError()) {
- return WriteResult{0, offsetResult.getError()};
+ return DrainResult{0, offsetResult.getError()};
}
return self.write(source, sourceSize, length, offsetResult.getOkay());
}
template <typename T>
- [[nodiscard]] WriteResult write(const T& source, size_t sourceSize, size_t length, size_t offset)
+ [[nodiscard]] DrainResult write(const T& source, size_t sourceSize, size_t length, size_t offset)
{
static_assert(not std::is_pointer_v<decltype(source)>);
auto& self = static_cast<Derived&>(*this);