Fix build on Windows

main
Luis Díaz Más 3 years ago committed by Luis Diaz
parent 405f4b5f1b
commit f5c89a4e62

@ -4,7 +4,6 @@ add_executable( exiv2
actions.cpp actions.hpp actions.cpp actions.hpp
getopt.cpp getopt.hpp getopt.cpp getopt.hpp
app_utils.cpp app_utils.hpp app_utils.cpp app_utils.hpp
$<TARGET_OBJECTS:exiv2lib_int>
) )
target_include_directories(exiv2 PRIVATE ${CMAKE_SOURCE_DIR}/src) # To find i18n.hpp target_include_directories(exiv2 PRIVATE ${CMAKE_SOURCE_DIR}/src) # To find i18n.hpp

@ -1983,12 +1983,11 @@ namespace {
char basename[max]; char basename[max];
std::memset(basename, 0x0, max); std::memset(basename, 0x0, max);
if (strftime(basename, max, format.c_str(), tm) == 0) { if (strftime(basename, max, format.c_str(), tm) == 0) {
std::cerr << _("Filename format yields empty filename for the file") << " " std::cerr << _("Filename format yields empty filename for the file") << " " << path << "\n";
<< path << "\n";
return 1; return 1;
} }
newPath = p.parent_path() / (basename + p.extension().string()); newPath = (p.parent_path() / (basename + p.extension().string())).string();
p = fs::path(newPath); p = fs::path(newPath);
if (p.parent_path() == oldFsPath.parent_path() && p.filename() == oldFsPath.filename()) { if (p.parent_path() == oldFsPath.parent_path() && p.filename() == oldFsPath.filename()) {
@ -2001,8 +2000,7 @@ namespace {
bool go = true; bool go = true;
int seq = 1; int seq = 1;
std::string s; std::string s;
Params::FileExistsPolicy fileExistsPolicy Params::FileExistsPolicy fileExistsPolicy = Params::instance().fileExistsPolicy_;
= Params::instance().fileExistsPolicy_;
while (go) { while (go) {
if (Exiv2::fileExists(newPath)) { if (Exiv2::fileExists(newPath)) {
switch (fileExistsPolicy) { switch (fileExistsPolicy) {
@ -2010,15 +2008,13 @@ namespace {
go = false; go = false;
break; break;
case Params::renamePolicy: case Params::renamePolicy:
newPath = p.parent_path() / (std::string(basename) + "_" newPath = (p.parent_path() /
+ Exiv2::toString(seq++) (std::string(basename) + "_" + Exiv2::toString(seq++) + p.extension().string()))
+ p.extension().string()); .string();
break; break;
case Params::askPolicy: case Params::askPolicy:
std::cout << Params::instance().progname() std::cout << Params::instance().progname() << ": " << _("File") << " `" << newPath << "' "
<< ": " << _("File") << " `" << newPath << _("exists. [O]verwrite, [r]ename or [s]kip?") << " ";
<< "' " << _("exists. [O]verwrite, [r]ename or [s]kip?")
<< " ";
std::cin >> s; std::cin >> s;
switch (s.at(0)) { switch (s.at(0)) {
case 'o': case 'o':
@ -2028,17 +2024,16 @@ namespace {
case 'r': case 'r':
case 'R': case 'R':
fileExistsPolicy = Params::renamePolicy; fileExistsPolicy = Params::renamePolicy;
newPath = p.parent_path() / (std::string(basename) + "_" newPath = (p.parent_path() / (std::string(basename) + "_" + Exiv2::toString(seq++) +
+ Exiv2::toString(seq++) p.extension().string()))
+ p.extension().string()); .string();
break; break;
default: // skip default: // skip
return -1; return -1;
break; break;
} }
} }
} } else {
else {
go = false; go = false;
} }
} }
@ -2054,15 +2049,13 @@ namespace {
// Workaround for MinGW rename which does not overwrite existing files // Workaround for MinGW rename which does not overwrite existing files
remove(newPath.c_str()); remove(newPath.c_str());
if (std::rename(path.c_str(), newPath.c_str()) == -1) { if (std::rename(path.c_str(), newPath.c_str()) == -1) {
std::cerr << Params::instance().progname() std::cerr << Params::instance().progname() << ": " << _("Failed to rename") << " " << path << " " << _("to")
<< ": " << _("Failed to rename") << " " << " " << newPath << ": " << Exiv2::strError() << "\n";
<< path << " " << _("to") << " " << newPath << ": "
<< Exiv2::strError() << "\n";
return 1; return 1;
} }
return 0; return 0;
} // renameFile }
std::string newFilePath(const std::string& path, const std::string& ext) std::string newFilePath(const std::string& path, const std::string& ext)
{ {
@ -2072,7 +2065,7 @@ namespace {
directory = p.parent_path(); directory = p.parent_path();
if (Exiv2::fileProtocol(path) != Exiv2::pFile) if (Exiv2::fileProtocol(path) != Exiv2::pFile)
directory.clear(); // use current directory for remote files directory.clear(); // use current directory for remote files
return directory / (p.stem().string() + ext); return (directory / (p.stem().string() + ext)).string();
} }
int dontOverwrite(const std::string& path) int dontOverwrite(const std::string& path)

Loading…
Cancel
Save