From 74e640bd7ea3941665375a3e838c079c63d430fa Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Thu, 19 Oct 2023 18:09:25 +0000 Subject: [PATCH] basicio: use fs::path in Impl Signed-off-by: Rosen Penev --- include/exiv2/basicio.hpp | 8 ++++---- src/basicio.cpp | 16 ++++++++-------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/include/exiv2/basicio.hpp b/include/exiv2/basicio.hpp index 179220464a..1a7e41e93b 100644 --- a/include/exiv2/basicio.hpp +++ b/include/exiv2/basicio.hpp @@ -218,7 +218,7 @@ class EXIV2API BasicIo { comprehensive error messages where only a BasicIo instance is available. */ - [[nodiscard]] virtual const std::string& path() const noexcept = 0; + [[nodiscard]] virtual std::string path() const noexcept = 0; /*! @brief Mark all the bNone blocks to bKnow. This avoids allocating memory @@ -455,7 +455,7 @@ class EXIV2API FileIo : public BasicIo { //! Returns true if the file position has reached the end, otherwise false. [[nodiscard]] bool eof() const override; //! Returns the path of the file - [[nodiscard]] const std::string& path() const noexcept override; + [[nodiscard]] std::string path() const noexcept override; /*! @brief Mark all the bNone blocks to bKnow. This avoids allocating memory @@ -636,7 +636,7 @@ class EXIV2API MemIo : public BasicIo { //! Returns true if the IO position has reached the end, otherwise false. [[nodiscard]] bool eof() const override; //! Returns a dummy path, indicating that memory access is used - [[nodiscard]] const std::string& path() const noexcept override; + [[nodiscard]] std::string path() const noexcept override; /*! @brief Mark all the bNone blocks to bKnow. This avoids allocating memory @@ -886,7 +886,7 @@ class EXIV2API RemoteIo : public BasicIo { //! Returns true if the IO position has reached the end, otherwise false. [[nodiscard]] bool eof() const override; //! Returns the URL of the file. - [[nodiscard]] const std::string& path() const noexcept override; + [[nodiscard]] std::string path() const noexcept override; /*! @brief Mark all the bNone blocks to bKnow. This avoids allocating memory diff --git a/src/basicio.cpp b/src/basicio.cpp index 15d0bf7534..f4dea3bf79 100644 --- a/src/basicio.cpp +++ b/src/basicio.cpp @@ -77,13 +77,13 @@ void BasicIo::seekOrThrow(int64_t offset, Position pos, ErrorCode err) { class FileIo::Impl { public: //! Constructor - explicit Impl(std::string path); + explicit Impl(fs::path path); ~Impl() = default; // Enumerations //! Mode of operation enum OpMode { opRead, opWrite, opSeek }; // DATA - std::string path_; //!< (Standard) path + fs::path path_; //!< (Standard) path std::string openMode_; //!< File open mode FILE* fp_{}; //!< File stream pointer OpMode opMode_{opSeek}; //!< File open mode @@ -118,7 +118,7 @@ class FileIo::Impl { Impl& operator=(const Impl&) = delete; //!< Assignment }; -FileIo::Impl::Impl(std::string path) : path_(std::move(path)) { +FileIo::Impl::Impl(fs::path path) : path_(std::move(path)) { } int FileIo::Impl::switchMode(OpMode opMode) { @@ -168,7 +168,7 @@ int FileIo::Impl::switchMode(OpMode opMode) { std::fclose(fp_); openMode_ = "r+b"; opMode_ = opSeek; - fp_ = std::fopen(path_.c_str(), openMode_.c_str()); + fp_ = std::fopen(path_.string().c_str(), openMode_.c_str()); if (!fp_) return 1; #ifdef _WIN32 @@ -544,8 +544,8 @@ bool FileIo::eof() const { return std::feof(p_->fp_) != 0; } -const std::string& FileIo::path() const noexcept { - return p_->path_; +std::string FileIo::path() const noexcept { + return p_->path_.string(); } void FileIo::populateFakeData() { @@ -844,7 +844,7 @@ bool MemIo::eof() const { return p_->eof_; } -const std::string& MemIo::path() const noexcept { +std::string MemIo::path() const noexcept { static std::string _path{"MemIo"}; return _path; } @@ -1353,7 +1353,7 @@ bool RemoteIo::eof() const { return p_->eof_; } -const std::string& RemoteIo::path() const noexcept { +std::string RemoteIo::path() const noexcept { return p_->path_; }