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 1624f4b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 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();
}

// don't 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
1 change: 1 addition & 0 deletions Sts1CobcSw/FileSystem/LfsWrapper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class File
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 1624f4b

Please sign in to comment.