summaryrefslogtreecommitdiff
path: root/include/fud_c_file.hpp
diff options
context:
space:
mode:
authorDominick Allen <djallen@librehumanitas.org>2024-10-02 13:53:56 -0500
committerDominick Allen <djallen@librehumanitas.org>2024-10-02 13:53:56 -0500
commitdf97d415ecb51688602a2fc2955199c06f14585c (patch)
tree96b4987c2e96408480ad80dc4d58524880e844e7 /include/fud_c_file.hpp
parentc2776f660e00dd9c0ec4cc50369b2a9cf2ed3e70 (diff)
Fix bug that allowed any pointer to be used as a writing or reading type.
Diffstat (limited to 'include/fud_c_file.hpp')
-rw-r--r--include/fud_c_file.hpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/include/fud_c_file.hpp b/include/fud_c_file.hpp
index 0d52e95..3b7d821 100644
--- a/include/fud_c_file.hpp
+++ b/include/fud_c_file.hpp
@@ -256,6 +256,7 @@ class CFile {
template <typename T>
[[nodiscard]] ReadResult read(T& destination, size_t length)
{
+ static_assert(not std::is_pointer_v<decltype(destination)>);
auto& self = static_cast<Derived&>(*this);
return self.read(destination, length, 0);
}
@@ -263,6 +264,7 @@ class CFile {
template <typename T>
[[nodiscard]] ReadResult 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);
}
@@ -342,6 +344,7 @@ class CFile {
template <typename T>
[[nodiscard]] WriteResult write(const T& source)
{
+ static_assert(not std::is_pointer_v<decltype(source)>);
auto& self = static_cast<Derived&>(*this);
return self.write(source, sizeof(source), sizeof(source));
}
@@ -349,8 +352,9 @@ class CFile {
template <typename T>
[[nodiscard]] WriteResult 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 = size();
+ auto offsetResult = self.size();
if (offsetResult.isError()) {
return WriteResult{0, offsetResult.getError()};
}
@@ -360,6 +364,7 @@ class CFile {
template <typename T>
[[nodiscard]] WriteResult 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);
return self.write(static_cast<const void*>(&source), sourceSize, length, offset);
}