Skip to content

Commit

Permalink
some fs::path conversions
Browse files Browse the repository at this point in the history
Signed-off-by: Rosen Penev <[email protected]>
  • Loading branch information
neheb committed Nov 21, 2024
1 parent 22694d7 commit 5ba703f
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions app/actions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ std::string tm2Str(const tm* tm);
be kept.
@return 0 if successful, else an error code
*/
int metacopy(const std::string& source, const std::string& tgt, Exiv2::ImageType targetType, bool preserve);
int metacopy(const std::string& source, const fs::path& tgt, Exiv2::ImageType targetType, bool preserve);

/*!
@brief Rename a file according to a timestamp value.
Expand All @@ -107,7 +107,7 @@ int metacopy(const std::string& source, const std::string& tgt, Exiv2::ImageType
the file to.
@return 0 if successful, -1 if the file was skipped, 1 on error.
*/
int renameFile(std::string& path, const tm* tm);
int renameFile(fs::path& path, const tm* tm);

/*!
@brief Make a file path from the current file path, destination
Expand Down Expand Up @@ -646,7 +646,7 @@ int Rename::run(const std::string& path) {
ts.read(&tm);
}
int rc = 0;
std::string newPath = path;
fs::path newPath = path;
if (Params::instance().timestampOnly_) {
if (Params::instance().verbose_) {
std::cout << _("Updating timestamp to") << " " << v << '\n';
Expand Down Expand Up @@ -1668,7 +1668,7 @@ std::string tm2Str(const tm* tm) {
return os.str();
} // tm2Str

std::string temporaryPath() {
fs::path temporaryPath() {
static int count = 0;
auto guard = std::scoped_lock(cs);

Expand All @@ -1683,10 +1683,10 @@ std::string temporaryPath() {
fs::remove(p);
}

return p.string();
return p;
}

int metacopy(const std::string& source, const std::string& tgt, Exiv2::ImageType targetType, bool preserve) {
int metacopy(const std::string& source, const fs::path& tgt, Exiv2::ImageType targetType, bool preserve) {
#ifdef EXIV2_DEBUG_MESSAGES
std::cerr << "actions.cpp::metacopy"
<< " source = " << source << " target = " << tgt << '\n';
Expand Down Expand Up @@ -1718,7 +1718,7 @@ int metacopy(const std::string& source, const std::string& tgt, Exiv2::ImageType
Action::Modify::applyCommands(sourceImage.get());

// Open or create the target file
std::string target(bStdout ? temporaryPath() : tgt);
fs::path target(bStdout ? temporaryPath() : tgt);

std::unique_ptr<Exiv2::Image> targetImage;
if (Exiv2::fileExists(target)) {
Expand Down Expand Up @@ -1819,7 +1819,7 @@ void replace(std::string& text, const std::string& searchText, const std::string
}
}

int renameFile(std::string& newPath, const tm* tm) {
int renameFile(fs::path& newPath, const tm* tm) {
auto p = fs::path(newPath);
std::string path = newPath;
auto oldFsPath = fs::path(path);
Expand Down

0 comments on commit 5ba703f

Please sign in to comment.