diff --git a/app/actions.cpp b/app/actions.cpp
index 6175a982..d8c91ddd 100644
--- a/app/actions.cpp
+++ b/app/actions.cpp
@@ -268,7 +268,7 @@ namespace Action {
int Print::printSummary()
{
- if (!Exiv2::fileExists(path_, true)) {
+ if (!Exiv2::fileExists(path_)) {
std::cerr << path_ << ": " << _("Failed to open the file\n");
return -1;
}
@@ -402,7 +402,7 @@ namespace Action {
int Print::printList()
{
- if (!Exiv2::fileExists(path_, true)) {
+ if (!Exiv2::fileExists(path_)) {
std::cerr << path_ << ": " << _("Failed to open the file\n");
return -1;
}
@@ -607,7 +607,7 @@ namespace Action {
int Print::printComment()
{
- if (!Exiv2::fileExists(path_, true)) {
+ if (!Exiv2::fileExists(path_)) {
std::cerr << path_ << ": " << _("Failed to open the file\n");
return -1;
}
@@ -624,7 +624,7 @@ namespace Action {
int Print::printPreviewList()
{
- if (!Exiv2::fileExists(path_, true)) {
+ if (!Exiv2::fileExists(path_)) {
std::cerr << path_ << ": " << _("Failed to open the file\n");
return -1;
}
@@ -658,7 +658,7 @@ namespace Action {
int Rename::run(const std::string& path)
{
try {
- if (!Exiv2::fileExists(path, true)) {
+ if (!Exiv2::fileExists(path)) {
std::cerr << path << ": " << _("Failed to open the file\n");
return -1;
}
@@ -740,7 +740,7 @@ namespace Action {
try {
path_ = path;
- if (!Exiv2::fileExists(path_, true)) {
+ if (!Exiv2::fileExists(path_)) {
std::cerr << path_ << ": " << _("Failed to open the file\n");
return -1;
}
@@ -900,7 +900,7 @@ namespace Action {
int Extract::writeThumbnail() const
{
- if (!Exiv2::fileExists(path_, true)) {
+ if (!Exiv2::fileExists(path_)) {
std::cerr << path_ << ": " << _("Failed to open the file\n");
return -1;
}
@@ -947,7 +947,7 @@ namespace Action {
int Extract::writePreviews() const
{
- if (!Exiv2::fileExists(path_, true)) {
+ if (!Exiv2::fileExists(path_)) {
std::cerr << path_ << ": " << _("Failed to open the file\n");
return -1;
}
@@ -983,7 +983,7 @@ namespace Action {
int Extract::writeIccProfile(const std::string& target) const
{
int rc = 0;
- if (!Exiv2::fileExists(path_, true)) {
+ if (!Exiv2::fileExists(path_)) {
std::cerr << path_ << ": " << _("Failed to open the file\n");
rc = -1;
}
@@ -1049,7 +1049,7 @@ namespace Action {
// -i{tgt}- reading from stdin?
bool bStdin = (Params::instance().target_ & Params::ctStdInOut) != 0;
- if (!Exiv2::fileExists(path, true)) {
+ if (!Exiv2::fileExists(path)) {
std::cerr << path
<< ": " << _("Failed to open the file\n");
return -1;
@@ -1106,12 +1106,12 @@ namespace Action {
Params::instance().getStdin(xmpBlob);
rc = insertXmpPacket(path,xmpBlob,true);
} else {
- if (!Exiv2::fileExists(xmpPath, true)) {
+ if (!Exiv2::fileExists(xmpPath)) {
std::cerr << xmpPath
<< ": " << _("Failed to open the file\n");
rc = -1;
}
- if (rc == 0 && !Exiv2::fileExists(path, true)) {
+ if (rc == 0 && !Exiv2::fileExists(path)) {
std::cerr << path
<< ": " << _("Failed to open the file\n");
rc = -1;
@@ -1152,7 +1152,7 @@ namespace Action {
Params::instance().getStdin(iccProfile);
rc = insertIccProfile(path,std::move(iccProfile));
} else {
- if (!Exiv2::fileExists(iccProfilePath, true)) {
+ if (!Exiv2::fileExists(iccProfilePath)) {
std::cerr << iccProfilePath
<< ": " << _("Failed to open the file\n");
rc = -1;
@@ -1168,7 +1168,7 @@ namespace Action {
{
int rc = 0;
// test path exists
- if (!Exiv2::fileExists(path, true)) {
+ if (!Exiv2::fileExists(path)) {
std::cerr << path << ": " << _("Failed to open the file\n");
rc=-1;
}
@@ -1192,12 +1192,12 @@ namespace Action {
int Insert::insertThumbnail(const std::string& path)
{
std::string thumbPath = newFilePath(path, "-thumb.jpg");
- if (!Exiv2::fileExists(thumbPath, true)) {
+ if (!Exiv2::fileExists(thumbPath)) {
std::cerr << thumbPath
<< ": " << _("Failed to open the file\n");
return -1;
}
- if (!Exiv2::fileExists(path, true)) {
+ if (!Exiv2::fileExists(path)) {
std::cerr << path
<< ": " << _("Failed to open the file\n");
return -1;
@@ -1220,7 +1220,7 @@ namespace Action {
int Modify::run(const std::string& path)
{
try {
- if (!Exiv2::fileExists(path, true)) {
+ if (!Exiv2::fileExists(path)) {
std::cerr << path << ": " << _("Failed to open the file\n");
return -1;
}
@@ -1452,7 +1452,7 @@ namespace Action {
monthAdjustment_ = Params::instance().yodAdjust_[Params::yodMonth].adjustment_;
dayAdjustment_ = Params::instance().yodAdjust_[Params::yodDay].adjustment_;
- if (!Exiv2::fileExists(path, true)) {
+ if (!Exiv2::fileExists(path)) {
std::cerr << path << ": " << _("Failed to open the file\n");
return -1;
}
@@ -1579,7 +1579,7 @@ namespace Action {
int FixIso::run(const std::string& path)
{
try {
- if (!Exiv2::fileExists(path, true)) {
+ if (!Exiv2::fileExists(path)) {
std::cerr << path << ": " <<_("Failed to open the file\n");
return -1;
}
@@ -1632,7 +1632,7 @@ namespace Action {
int FixCom::run(const std::string& path)
{
try {
- if (!Exiv2::fileExists(path, true)) {
+ if (!Exiv2::fileExists(path)) {
std::cerr << path << ": " <<_("Failed to open the file\n");
return -1;
}
@@ -1821,7 +1821,7 @@ namespace {
// read the source metadata
int rc = -1 ;
- if (!Exiv2::fileExists(source, true)) {
+ if (!Exiv2::fileExists(source)) {
std::cerr << source << ": " << _("Failed to open the file\n");
return rc;
}
@@ -2096,7 +2096,7 @@ namespace {
int printStructure(std::ostream& out, Exiv2::PrintStructureOption option, const std::string &path)
{
- if (!Exiv2::fileExists(path, true)) {
+ if (!Exiv2::fileExists(path)) {
std::cerr << path << ": "
<< _("Failed to open the file\n");
return -1;
diff --git a/include/exiv2/futils.hpp b/include/exiv2/futils.hpp
index bcf88aa3..cebb19ac 100644
--- a/include/exiv2/futils.hpp
+++ b/include/exiv2/futils.hpp
@@ -114,7 +114,7 @@ namespace Exiv2
and its type, see stat(2). errno is left unchanged
in case of an error.
*/
- EXIV2API bool fileExists(const std::string& path, bool ct = false);
+ EXIV2API bool fileExists(const std::string& path);
/*!
@brief Get the path of file URL.
diff --git a/src/futils.cpp b/src/futils.cpp
index be1f3e91..ccceaedd 100644
--- a/src/futils.cpp
+++ b/src/futils.cpp
@@ -27,19 +27,23 @@
#include "image_int.hpp"
// + standard includes
-#include
#include
-#include
-#include
-#include
-#include
-#include
+#include
+
#include
+#include
+#include
+#include
+#include
+#include
+#include
#include
-#ifdef EXV_HAVE_UNISTD_H
-#include // for stat()
+#ifdef EXV_HAVE_UNISTD_H
+#include // for stat()
#endif
+namespace fs = std::filesystem;
+
#if defined(WIN32)
#include
#include // For access to GetModuleFileNameEx
@@ -243,19 +247,13 @@ namespace Exiv2 {
return result;
} // fileProtocol
- bool fileExists(const std::string& path, bool ct)
+ bool fileExists(const std::string& path)
{
- // special case: accept "-" (means stdin)
- if (path == "-" || fileProtocol(path) != pFile) {
+ if (fileProtocol(path) != pFile) {
return true;
}
-
- struct stat buf;
- int ret = ::stat(path.c_str(), &buf);
- if (0 != ret) return false;
- if (ct && !S_ISREG(buf.st_mode)) return false;
- return true;
- } // fileExists
+ return fs::exists(path);
+ }
std::string pathOfFileUrl(const std::string& url) {
std::string path = url.substr(7);
diff --git a/src/version.cpp b/src/version.cpp
index d1982caf..5576a0a8 100644
--- a/src/version.cpp
+++ b/src/version.cpp
@@ -139,7 +139,7 @@ static void output(std::ostream& os,const std::vector& greps,const c
static bool pushPath(std::string& path,std::vector& libs,std::set& paths)
{
- bool result = Exiv2::fileExists(path,true) && paths.find(path) == paths.end() && path != "/" ;
+ bool result = Exiv2::fileExists(path) && paths.find(path) == paths.end() && path != "/" ;
if ( result ) {
paths.insert(path);
libs.push_back(path);
diff --git a/test/data/template.exv b/test/data/template.exv
index 91633251..8ec5db04 100644
Binary files a/test/data/template.exv and b/test/data/template.exv differ