-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a proper File
class
#287
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #287 +/- ##
===========================================
- Coverage 97.69% 85.72% -11.97%
===========================================
Files 33 37 +4
Lines 1039 1184 +145
Branches 25 48 +23
===========================================
Hits 1015 1015
- Misses 24 169 +145 ☔ View full report in Codecov by Sentry. |
83f4d0d
to
f2bd985
Compare
ac96f14
to
d9b457d
Compare
95a1b61
to
51d8ccd
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-
add_compile_definitions(USE_NO_RODOS)
in the top-level CML file seems wrong -
Read/Write()
should be likefram::ReadFrom/WriteTo()
, i.e. they should take byte spans:template<std::size_t extent> [[nodiscard]] auto Read(std::span<Byte, extent> data) const -> Result<int>; template<std::size_t extent> [[nodiscard]] auto Write(std::span<const Byte, extent> data) -> Result<int>;
-
Rename
Read/WriteInternal()
to justRead/Write()
. The private functions have different parameters, so there is no reason to give them different names for disambiguation (function overloading FTW). -
Use the same order for the public and private
Read/Write()
functions
The TEST_CASE()s and other magic from Catch2 made it harder to debug.
This requires addinge the members path_ and openFlags_.
When using designated initializes to initialize a struct, it is perfectly valid not to specify all fields. The unspecified fields are initialized with default member initializers where provided, and empty list-initialization otherwise.
The normal lfs_file_open() uses malloc() to allocate the file buffer. Since we do not want to use the heap, we use lfs_file_opencfg() and provide a statically allocated buffer instead.
This reverts commit 1d0bd2f. In this special case the Swap() function is an abomination, and the previous version with the Move() function is better.
- Rename `Move()` to `MoveConstructFrom()` - Make the class const-correct - Remove `std::cout` and `iostream` - Make cosmetic changes
They were used to test stuff during development but are now obsolete.
The longest path should be "/programs/65536.zip.lock" which is only 25 characters long, so we can save quite a bit of memory when we reduce the max path length from the default 256 to just 30.
45988ae
to
62a2058
Compare
- Always pass paths as `Path` aka `etl::string` and use `c_str()` to ensure that the littlefs functions get null-terminated strings - Move member variables which are only used in `CreateLockFile()` to that function
Eventually, the `File` class will need semaphores and therefore require the main function from Rodos. I converted it now, because that allows me to get rid of this `USE_NO_RODOS` nonsense in `Outcome.hpp` too.
62a2058
to
8fae95c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Make
CreateLockFile()
andClose()
const
- In
Open()
when callingCreateLockFile()
either useOUTCOME_TRY(file.CreateLockFile());
or create (and return) a new, specific error code for this, likefileLocked
- Instead of removing the lock file in
MoveConstructFrom()
by callingClose()
and creating it again later, we should add a privateCloseAndKeepLockFile()
function that we call instead.Close()
should then also call this function and additionally remove the lock file.
22b5b59
to
1624f4b
Compare
Description
Add class
File
as part of the wrapper for littlefs.Fixes parts of #273
Fixes parts of #186
Fixes parts of #209