Skip to content

Commit

Permalink
Do not use protected data members
Browse files Browse the repository at this point in the history
  • Loading branch information
bugdea1er committed Jan 28, 2024
1 parent 2dfae82 commit ceafa38
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions include/tmp/path.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ namespace tmp {
/// Subclass this and provide mktemp-like function to the constructor to create
/// temporary files and directories.
class path {
std::filesystem::path underlying; ///< This path

public:
/// Returns the underlying path
operator const std::filesystem::path&() const noexcept;
Expand All @@ -28,8 +30,6 @@ class path {
auto operator=(const path&) = delete; ///< not copy-assignable

protected:
std::filesystem::path underlying; ///< This file path

/// Creates a unique temporary path using the given constructor function.
/// @param prefix the path between system temp
/// @param creator wrapped mktemp-like function that returns resulting path
Expand Down
4 changes: 2 additions & 2 deletions lib/file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ std::filesystem::path file::create(std::string_view prefix) {
std::ofstream file::stream(bool append) const noexcept {
std::ios::openmode mode = append ? std::ios::app : std::ios::trunc;
return this->binary
? std::ofstream { this->underlying, mode | std::ios::binary }
: std::ofstream { this->underlying, mode };
? std::ofstream { static_cast<const std::filesystem::path&>(*this), mode | std::ios::binary }
: std::ofstream { static_cast<const std::filesystem::path&>(*this), mode };
};

} // namespace tmp

0 comments on commit ceafa38

Please sign in to comment.