Skip to content
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

basicio: use fs::path in Impl #2800

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions include/exiv2/basicio.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
16 changes: 8 additions & 8 deletions src/basicio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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_;
}

Expand Down