Skip to content

Commit

Permalink
Add closeAndKeepLockFile for LfsWrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
flo12356 committed Oct 8, 2024
1 parent 8fae95c commit 22b5b59
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
22 changes: 20 additions & 2 deletions Sts1CobcSw/FileSystem/LfsWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,12 +153,30 @@ auto File::MoveConstructFrom(File * other) noexcept -> void
openFlags_ = other->openFlags_;
isOpen_ = true;
}
(void)other->Close();
(void)other->CloseAndKeepLockFile();
other->path_ = "";
other->lockFilePath_ = "";
other->openFlags_ = 0;
other->lfsFile_ = {};
(void)CreateLockFile(); // TODO handle lock file error
}


auto File::CloseAndKeepLockFile() -> Result<void>
{
if(not isOpen_)
{
return outcome_v2::success();
}

// dont remove lock file here

auto error = lfs_file_close(&lfs, &lfsFile_);
if(error != 0)
{
return static_cast<ErrorCode>(error);
}
isOpen_ = false;
return outcome_v2::success();
}


Expand Down
2 changes: 1 addition & 1 deletion Sts1CobcSw/FileSystem/LfsWrapper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class File
// Only allow creation of File class through friend function Open()
File() = default;
auto MoveConstructFrom(File * other) noexcept -> void;
[[nodiscard]] auto CreateLockFile() noexcept -> Result<void>;
[[nodiscard]] auto CloseAndKeepLockFile() -> Result<void>;
[[nodiscard]] auto Read(void * buffer, std::size_t size) const -> Result<int>;
[[nodiscard]] auto Write(void const * buffer, std::size_t size) -> Result<int>;

Expand Down

0 comments on commit 22b5b59

Please sign in to comment.