diff --git a/Sts1CobcSw/FileSystem/LfsWrapper.cpp b/Sts1CobcSw/FileSystem/LfsWrapper.cpp index 8d691946..2dcc721f 100644 --- a/Sts1CobcSw/FileSystem/LfsWrapper.cpp +++ b/Sts1CobcSw/FileSystem/LfsWrapper.cpp @@ -45,10 +45,11 @@ auto Unmount() -> Result } -auto Open(std::string_view path, int flags) -> Result +auto Open(std::string_view path, unsigned int flags) -> Result { auto file = File(); - auto error = lfs_file_opencfg(&lfs, &file.lfsFile_, path.data(), flags, &file.lfsFileConfig_); + auto error = lfs_file_opencfg( + &lfs, &file.lfsFile_, path.data(), static_cast(flags), &file.lfsFileConfig_); if(error == 0) { file.path_ = Path(path.data(), path.size()); @@ -66,8 +67,8 @@ File::File(File && other) noexcept { return; } - auto error = - lfs_file_opencfg(&lfs, &lfsFile_, other.path_.c_str(), other.openFlags_, &lfsFileConfig_); + auto error = lfs_file_opencfg( + &lfs, &lfsFile_, other.path_.c_str(), static_cast(other.openFlags_), &lfsFileConfig_); if(error == 0) { path_ = other.path_; @@ -86,8 +87,11 @@ auto File::operator=(File && other) noexcept -> File & // TODO: Use copy and swap idiom to prevent code duplication from move constructor if(this != &other and not other.path_.empty()) { - auto error = lfs_file_opencfg( - &lfs, &lfsFile_, other.path_.c_str(), other.openFlags_, &lfsFileConfig_); + auto error = lfs_file_opencfg(&lfs, + &lfsFile_, + other.path_.c_str(), + static_cast(other.openFlags_), + &lfsFileConfig_); if(error == 0) { path_ = other.path_; diff --git a/Sts1CobcSw/FileSystem/LfsWrapper.hpp b/Sts1CobcSw/FileSystem/LfsWrapper.hpp index e39904f2..1395bdb9 100644 --- a/Sts1CobcSw/FileSystem/LfsWrapper.hpp +++ b/Sts1CobcSw/FileSystem/LfsWrapper.hpp @@ -27,7 +27,7 @@ class File; [[nodiscard]] auto Mount() -> Result; [[nodiscard]] auto Unmount() -> Result; -[[nodiscard]] auto Open(std::string_view path, int flags) -> Result; +[[nodiscard]] auto Open(std::string_view path, unsigned int flags) -> Result; // FIXME: Make File const-correct (only Write() should be non-const) @@ -51,15 +51,15 @@ class File [[nodiscard]] auto Size() -> Result; [[nodiscard]] auto Close() -> Result; - friend auto Open(std::string_view path, int flags) -> Result; + friend auto Open(std::string_view path, unsigned int flags) -> Result; private: // Only allow creation of File class through friend function Open() File() = default; Path path_ = ""; - int openFlags_ = 0; bool isOpen_ = false; + unsigned int openFlags_ = 0; std::array buffer_ = {}; lfs_file_t lfsFile_ = {}; lfs_file_config lfsFileConfig_ = {.buffer = buffer_.data()}; diff --git a/Sts1CobcSw/FileSystem/LfsWrapper.ipp b/Sts1CobcSw/FileSystem/LfsWrapper.ipp index 74fc8b13..e471afd9 100644 --- a/Sts1CobcSw/FileSystem/LfsWrapper.ipp +++ b/Sts1CobcSw/FileSystem/LfsWrapper.ipp @@ -16,7 +16,7 @@ auto File::Read(T * t) -> Result { return ErrorCode::fileNotOpen; } - if(not(static_cast(openFlags_) & LFS_O_RDONLY)) + if(not(openFlags_ & LFS_O_RDONLY)) { return ErrorCode::unsupportedOperation; } @@ -36,7 +36,7 @@ auto File::Write(T const & t) -> Result { return ErrorCode::fileNotOpen; } - if(not(static_cast(openFlags_) & LFS_O_WRONLY)) + if(not(openFlags_ & LFS_O_WRONLY)) { return ErrorCode::unsupportedOperation; }