diff --git a/app/actions.cpp b/app/actions.cpp index be3a249093..79a7a2f4f7 100644 --- a/app/actions.cpp +++ b/app/actions.cpp @@ -216,17 +216,17 @@ int Print::run(const fs::path& path) { } return 0; } catch (const Exiv2::Error& e) { - std::cerr << "Exiv2 exception in print action for file " << path << ":\n" << e << "\n"; + std::cerr << "Exiv2 exception in print action for file " << path.c_str() << ":\n" << e << "\n"; return 1; } catch (const std::overflow_error& e) { - std::cerr << "std::overflow_error exception in print action for file " << path << ":\n" << e.what() << "\n"; + std::cerr << "std::overflow_error exception in print action for file " << path.c_str() << ":\n" << e.what() << "\n"; return 1; } } int Print::printSummary() { if (!Exiv2::fileExists(path_)) { - std::cerr << path_ << ": " << _("Failed to open the file") << "\n"; + std::cerr << path_.c_str() << ": " << _("Failed to open the file") << "\n"; return -1; } @@ -237,7 +237,7 @@ int Print::printSummary() { // Filename printLabel(_("File name")); - std::cout << path_ << '\n'; + std::cout << path_.c_str() << '\n'; // Filesize printLabel(_("File size")); @@ -252,7 +252,7 @@ int Print::printSummary() { std::cout << image->pixelWidth() << " x " << image->pixelHeight() << '\n'; if (exifData.empty()) { - std::cerr << path_ << ": " << _("No Exif data found in the file") << "\n"; + std::cerr << path_.c_str() << ": " << _("No Exif data found in the file") << "\n"; return -3; } @@ -300,7 +300,7 @@ int Print::printSummary() { void Print::printLabel(const std::string& label) const { std::cout << std::setfill(' ') << std::left; if (Params::instance().files_.size() > 1) { - std::cout << std::setw(20) << path_ << " "; + std::cout << std::setw(20) << path_.c_str() << " "; } std::cout << std::pair(label, align_) << ": "; } @@ -345,7 +345,7 @@ int Print::printTag(const Exiv2::ExifData& exifData, EasyAccessFct easyAccessFct int Print::printList() { if (!Exiv2::fileExists(path_)) { - std::cerr << path_ << ": " << _("Failed to open the file") << "\n"; + std::cerr << path_.c_str() << ": " << _("Failed to open the file") << "\n"; return -1; } @@ -396,11 +396,11 @@ int Print::printMetadata(const Exiv2::Image* image) { // With -v, inform about the absence of any (requested) type of metadata if (Params::instance().verbose_) { if (noExif) - std::cerr << path_ << ": " << _("No Exif data found in the file") << "\n"; + std::cerr << path_.c_str() << ": " << _("No Exif data found in the file") << "\n"; if (noIptc) - std::cerr << path_ << ": " << _("No IPTC data found in the file") << "\n"; + std::cerr << path_.c_str() << ": " << _("No IPTC data found in the file") << "\n"; if (noXmp) - std::cerr << path_ << ": " << _("No XMP data found in the file") << "\n"; + std::cerr << path_.c_str() << ": " << _("No XMP data found in the file") << "\n"; } // With -g or -K, return -3 if no matching tags were found @@ -448,7 +448,7 @@ bool Print::printMetadatum(const Exiv2::Metadatum& md, const Exiv2::Image* pImag bool const manyFiles = Params::instance().files_.size() > 1; if (manyFiles) { - std::cout << std::setfill(' ') << std::left << std::setw(20) << path_ << " "; + std::cout << std::setfill(' ') << std::left << std::setw(20) << path_.c_str() << " "; } bool first = true; @@ -557,7 +557,7 @@ bool Print::printMetadatum(const Exiv2::Metadatum& md, const Exiv2::Image* pImag int Print::printComment() { if (!Exiv2::fileExists(path_)) { - std::cerr << path_ << ": " << _("Failed to open the file") << "\n"; + std::cerr << path_.c_str() << ": " << _("Failed to open the file") << "\n"; return -1; } @@ -572,7 +572,7 @@ int Print::printComment() { int Print::printPreviewList() { if (!Exiv2::fileExists(path_)) { - std::cerr << path_ << ": " << _("Failed to open the file") << "\n"; + std::cerr << path_.c_str() << ": " << _("Failed to open the file") << "\n"; return -1; } @@ -584,7 +584,7 @@ int Print::printPreviewList() { Exiv2::PreviewPropertiesList list = pm.getPreviewProperties(); for (const auto& pos : list) { if (manyFiles) { - std::cout << std::setfill(' ') << std::left << std::setw(20) << path_ << " "; + std::cout << std::setfill(' ') << std::left << std::setw(20) << path_.c_str() << " "; } std::cout << _("Preview") << " " << ++cnt << ": " << pos.mimeType_ << ", "; if (pos.width_ != 0 && pos.height_ != 0) { @@ -602,7 +602,7 @@ Task::UniquePtr Print::clone() const { int Rename::run(const fs::path& path) { try { if (!Exiv2::fileExists(path)) { - std::cerr << path << ": " << _("Failed to open the file") << "\n"; + std::cerr << path.c_str() << ": " << _("Failed to open the file") << "\n"; return -1; } Timestamp ts; @@ -613,7 +613,7 @@ int Rename::run(const fs::path& path) { image->readMetadata(); Exiv2::ExifData& exifData = image->exifData(); if (exifData.empty()) { - std::cerr << path << ": " << _("No Exif data found in the file") << "\n"; + std::cerr << path.c_str() << ": " << _("No Exif data found in the file") << "\n"; return -3; } auto md = exifData.findKey(Exiv2::ExifKey("Exif.Photo.DateTimeOriginal")); @@ -621,17 +621,17 @@ int Rename::run(const fs::path& path) { md = exifData.findKey(Exiv2::ExifKey("Exif.Image.DateTime")); if (md == exifData.end()) { std::cerr << _("Neither tag") << " `Exif.Photo.DateTimeOriginal' " << _("nor") << " `Exif.Image.DateTime' " - << _("found in the file") << " " << path << "\n"; + << _("found in the file") << " " << path.c_str() << "\n"; return 1; } std::string v = md->toString(); if (v.empty() || v.front() == ' ') { - std::cerr << _("Image file creation timestamp not set in the file") << " " << path << "\n"; + std::cerr << _("Image file creation timestamp not set in the file") << " " << path.c_str() << "\n"; return 1; } tm tm; if (str2Tm(v, &tm) != 0) { - std::cerr << _("Failed to parse timestamp") << " `" << v << "' " << _("in the file") << " " << path << "\n"; + std::cerr << _("Failed to parse timestamp") << " `" << v << "' " << _("in the file") << " " << path.c_str() << "\n"; return 1; } if (Params::instance().timestamp_ || Params::instance().timestampOnly_) { @@ -654,7 +654,7 @@ int Rename::run(const fs::path& path) { } return rc; } catch (const Exiv2::Error& e) { - std::cerr << "Exiv2 exception in rename action for file " << path << ":\n" << e << "\n"; + std::cerr << "Exiv2 exception in rename action for file " << path.c_str() << ":\n" << e << "\n"; return 1; } } @@ -668,7 +668,7 @@ int Erase::run(const fs::path& path) { path_ = path; if (!Exiv2::fileExists(path_)) { - std::cerr << path_ << ": " << _("Failed to open the file") << "\n"; + std::cerr << path_.c_str() << ": " << _("Failed to open the file") << "\n"; return -1; } Timestamp ts; @@ -709,7 +709,7 @@ int Erase::run(const fs::path& path) { return rc; } catch (const Exiv2::Error& e) { - std::cerr << "Exiv2 exception in erase action for file " << path << ":\n" << e << "\n"; + std::cerr << "Exiv2 exception in erase action for file " << path.c_str() << ":\n" << e << "\n"; return 1; } } @@ -807,28 +807,28 @@ int Extract::run(const fs::path& path) { } return rc; } catch (const Exiv2::Error& e) { - std::cerr << "Exiv2 exception in extract action for file " << path << ":\n" << e << "\n"; + std::cerr << "Exiv2 exception in extract action for file " << path.c_str() << ":\n" << e << "\n"; return 1; } } int Extract::writeThumbnail() const { if (!Exiv2::fileExists(path_)) { - std::cerr << path_ << ": " << _("Failed to open the file") << "\n"; + std::cerr << path_.c_str() << ": " << _("Failed to open the file") << "\n"; return -1; } auto image = Exiv2::ImageFactory::open(path_); image->readMetadata(); Exiv2::ExifData& exifData = image->exifData(); if (exifData.empty()) { - std::cerr << path_ << ": " << _("No Exif data found in the file") << "\n"; + std::cerr << path_.c_str() << ": " << _("No Exif data found in the file") << "\n"; return -3; } int rc = 0; Exiv2::ExifThumb exifThumb(exifData); std::string thumbExt = exifThumb.extension(); if (thumbExt.empty()) { - std::cerr << path_ << ": " << _("Image does not contain an Exif thumbnail") << "\n"; + std::cerr << path_.c_str() << ": " << _("Image does not contain an Exif thumbnail") << "\n"; } else { if ((Params::instance().target_ & Params::ctStdInOut) != 0) { Exiv2::DataBuf buf = exifThumb.copy(); @@ -849,7 +849,7 @@ int Extract::writeThumbnail() const { } rc = static_cast(exifThumb.writeFile(thumb)); if (rc == 0) { - std::cerr << path_ << ": " << _("Exif data doesn't contain a thumbnail") << "\n"; + std::cerr << path_.c_str() << ": " << _("Exif data doesn't contain a thumbnail") << "\n"; } } return rc; @@ -857,7 +857,7 @@ int Extract::writeThumbnail() const { int Extract::writePreviews() const { if (!Exiv2::fileExists(path_)) { - std::cerr << path_ << ": " << _("Failed to open the file") << "\n"; + std::cerr << path_.c_str() << ": " << _("Failed to open the file") << "\n"; return -1; } @@ -879,7 +879,7 @@ int Extract::writePreviews() const { } num--; if (num >= pvList.size()) { - std::cerr << path_ << ": " << _("Image does not have preview") << " " << num + 1 << "\n"; + std::cerr << path_.c_str() << ": " << _("Image does not have preview") << " " << num + 1 << "\n"; continue; } writePreviewFile(pvMgr.getPreviewImage(pvList[num]), num + 1); @@ -890,7 +890,7 @@ int Extract::writePreviews() const { int Extract::writeIccProfile(const std::string& target) const { int rc = 0; if (!Exiv2::fileExists(path_)) { - std::cerr << path_ << ": " << _("Failed to open the file") << "\n"; + std::cerr << path_.c_str() << ": " << _("Failed to open the file") << "\n"; rc = -1; } @@ -900,7 +900,7 @@ int Extract::writeIccProfile(const std::string& target) const { auto image = Exiv2::ImageFactory::open(path_); image->readMetadata(); if (!image->iccProfileDefined()) { - std::cerr << _("No embedded iccProfile: ") << path_ << '\n'; + std::cerr << _("No embedded iccProfile: ") << path_.c_str() << '\n'; rc = -2; } else { if (bStdout) { // -eC- @@ -933,7 +933,7 @@ void Extract::writePreviewFile(const Exiv2::PreviewImage& pvImg, size_t num) con } auto rc = pvImg.writeFile(pvFile); if (rc == 0) { - std::cerr << path_ << ": " << _("Image does not have preview") << " " << num << "\n"; + std::cerr << path_.c_str() << ": " << _("Image does not have preview") << " " << num << "\n"; } } @@ -946,7 +946,7 @@ int Insert::run(const fs::path& path) try { bool bStdin = (Params::instance().target_ & Params::ctStdInOut) != 0; if (!Exiv2::fileExists(path)) { - std::cerr << path << ": " << _("Failed to open the file") << "\n"; + std::cerr << path.c_str() << ": " << _("Failed to open the file") << "\n"; return -1; } @@ -985,7 +985,7 @@ int Insert::run(const fs::path& path) try { ts.touch(path); return rc; } catch (const Exiv2::Error& e) { - std::cerr << "Exiv2 exception in insert action for file " << path << ":\n" << e << "\n"; + std::cerr << "Exiv2 exception in insert action for file " << path.c_str() << ":\n" << e << "\n"; return 1; } // Insert::run @@ -1002,7 +1002,7 @@ int Insert::insertXmpPacket(const fs::path& path, const std::string& xmpPath) { rc = -1; } if (rc == 0 && !Exiv2::fileExists(path)) { - std::cerr << path << ": " << _("Failed to open the file") << "\n"; + std::cerr << path.c_str() << ": " << _("Failed to open the file") << "\n"; rc = -1; } if (rc == 0) { @@ -1053,7 +1053,7 @@ int Insert::insertIccProfile(const fs::path& path, Exiv2::DataBuf&& iccProfileBl int rc = 0; // test path exists if (!Exiv2::fileExists(path)) { - std::cerr << path << ": " << _("Failed to open the file") << "\n"; + std::cerr << path.c_str() << ": " << _("Failed to open the file") << "\n"; rc = -1; } @@ -1079,7 +1079,7 @@ int Insert::insertThumbnail(const fs::path& path) { return -1; } if (!Exiv2::fileExists(path)) { - std::cerr << path << ": " << _("Failed to open the file") << "\n"; + std::cerr << path.c_str() << ": " << _("Failed to open the file") << "\n"; return -1; } auto image = Exiv2::ImageFactory::open(path); @@ -1098,7 +1098,7 @@ Task::UniquePtr Insert::clone() const { int Modify::run(const fs::path& path) { try { if (!Exiv2::fileExists(path)) { - std::cerr << path << ": " << _("Failed to open the file") << "\n"; + std::cerr << path.c_str() << ": " << _("Failed to open the file") << "\n"; return -1; } Timestamp ts; @@ -1118,7 +1118,7 @@ int Modify::run(const fs::path& path) { return rc; } catch (const Exiv2::Error& e) { - std::cerr << "Exiv2 exception in modify action for file " << path << ":\n" << e << "\n"; + std::cerr << "Exiv2 exception in modify action for file " << path.c_str() << ":\n" << e << "\n"; return 1; } } // Modify::run @@ -1307,7 +1307,7 @@ int Adjust::run(const fs::path& path) try { dayAdjustment_ = Params::instance().yodAdjust_[Params::yodDay].adjustment_; if (!Exiv2::fileExists(path)) { - std::cerr << path << ": " << _("Failed to open the file") << "\n"; + std::cerr << path.c_str() << ": " << _("Failed to open the file") << "\n"; return -1; } Timestamp ts; @@ -1318,7 +1318,7 @@ int Adjust::run(const fs::path& path) try { image->readMetadata(); Exiv2::ExifData& exifData = image->exifData(); if (exifData.empty()) { - std::cerr << path << ": " << _("No Exif data found in the file") << "\n"; + std::cerr << path.c_str() << ": " << _("No Exif data found in the file") << "\n"; return -3; } int rc = adjustDateTime(exifData, "Exif.Image.DateTime", path); @@ -1333,7 +1333,7 @@ int Adjust::run(const fs::path& path) try { } return rc ? 1 : 0; } catch (const Exiv2::Error& e) { - std::cerr << "Exiv2 exception in adjust action for file " << path << ":\n" << e << "\n"; + std::cerr << "Exiv2 exception in adjust action for file " << path.c_str() << ":\n" << e << "\n"; return 1; } // Adjust::run @@ -1350,7 +1350,7 @@ int Adjust::adjustDateTime(Exiv2::ExifData& exifData, const std::string& key, co } std::string timeStr = md->toString(); if (timeStr.empty() || timeStr[0] == ' ') { - std::cerr << path << ": " << _("Timestamp of metadatum with key") << " `" << ek << "' " << _("not set") << "\n"; + std::cerr << path.c_str() << ": " << _("Timestamp of metadatum with key") << " `" << ek << "' " << _("not set") << "\n"; return 1; } if (Params::instance().verbose_) { @@ -1397,7 +1397,7 @@ int Adjust::adjustDateTime(Exiv2::ExifData& exifData, const std::string& key, co if (str2Tm(timeStr, &tm) != 0) { if (Params::instance().verbose_) std::cout << '\n'; - std::cerr << path << ": " << _("Failed to parse timestamp") << " `" << timeStr << "'\n"; + std::cerr << path.c_str() << ": " << _("Failed to parse timestamp") << " `" << timeStr << "'\n"; return 1; } @@ -1437,7 +1437,7 @@ int Adjust::adjustDateTime(Exiv2::ExifData& exifData, const std::string& key, co if (tm.tm_year > 9999 - 1900 || tm.tm_year < 1000 - 1900) { if (Params::instance().verbose_) std::cout << '\n'; - std::cerr << path << ": " << _("Can't adjust timestamp by") << " " << yearAdjustment + monOverflow << " " + std::cerr << path.c_str() << ": " << _("Can't adjust timestamp by") << " " << yearAdjustment + monOverflow << " " << _("years") << "\n"; return 1; } @@ -1454,7 +1454,7 @@ int Adjust::adjustDateTime(Exiv2::ExifData& exifData, const std::string& key, co int FixIso::run(const fs::path& path) { try { if (!Exiv2::fileExists(path)) { - std::cerr << path << ": " << _("Failed to open the file") << "\n"; + std::cerr << path.c_str() << ": " << _("Failed to open the file") << "\n"; return -1; } Timestamp ts; @@ -1465,7 +1465,7 @@ int FixIso::run(const fs::path& path) { image->readMetadata(); Exiv2::ExifData& exifData = image->exifData(); if (exifData.empty()) { - std::cerr << path << ": " << _("No Exif data found in the file") << "\n"; + std::cerr << path.c_str() << ": " << _("No Exif data found in the file") << "\n"; return -3; } auto md = Exiv2::isoSpeed(exifData); @@ -1490,7 +1490,7 @@ int FixIso::run(const fs::path& path) { return 0; } catch (const Exiv2::Error& e) { - std::cerr << "Exiv2 exception in fixiso action for file " << path << ":\n" << e << "\n"; + std::cerr << "Exiv2 exception in fixiso action for file " << path.c_str() << ":\n" << e << "\n"; return 1; } } // FixIso::run @@ -1502,7 +1502,7 @@ Task::UniquePtr FixIso::clone() const { int FixCom::run(const fs::path& path) { try { if (!Exiv2::fileExists(path)) { - std::cerr << path << ": " << _("Failed to open the file") << "\n"; + std::cerr << path.c_str() << ": " << _("Failed to open the file") << "\n"; return -1; } Timestamp ts; @@ -1513,7 +1513,7 @@ int FixCom::run(const fs::path& path) { image->readMetadata(); Exiv2::ExifData& exifData = image->exifData(); if (exifData.empty()) { - std::cerr << path << ": " << _("No Exif data found in the file") << "\n"; + std::cerr << path.c_str() << ": " << _("No Exif data found in the file") << "\n"; return -3; } auto pos = exifData.findKey(Exiv2::ExifKey("Exif.Photo.UserComment")); @@ -1551,7 +1551,7 @@ int FixCom::run(const fs::path& path) { return 0; } catch (const Exiv2::Error& e) { - std::cerr << "Exiv2 exception in fixcom action for file " << path << ":\n" << e << "\n"; + std::cerr << "Exiv2 exception in fixcom action for file " << path.c_str() << ":\n" << e << "\n"; return 1; } } // FixCom::run @@ -1681,13 +1681,13 @@ fs::path temporaryPath() { int metacopy(const fs::path& source, const fs::path& tgt, Exiv2::ImageType targetType, bool preserve) { #ifdef EXIV2_DEBUG_MESSAGES std::cerr << "actions.cpp::metacopy" - << " source = " << source << " target = " << tgt << '\n'; + << " source = " << source.c_str() << " target = " << tgt.c_str() << '\n'; #endif // read the source metadata int rc = -1; if (!Exiv2::fileExists(source)) { - std::cerr << source << ": " << _("Failed to open the file") << "\n"; + std::cerr << source.c_str() << ": " << _("Failed to open the file") << "\n"; return rc; } @@ -1723,7 +1723,7 @@ int metacopy(const fs::path& source, const fs::path& tgt, Exiv2::ImageType targe // Copy each type of metadata if (Params::instance().target_ & Params::ctExif && !sourceImage->exifData().empty()) { if (Params::instance().verbose_ && !bStdout) { - std::cout << _("Writing Exif data from") << " " << source << " " << _("to") << " " << target << '\n'; + std::cout << _("Writing Exif data from") << " " << source.c_str() << " " << _("to") << " " << target.c_str() << '\n'; } if (preserve) { for (const auto& exif : sourceImage->exifData()) { @@ -1735,7 +1735,7 @@ int metacopy(const fs::path& source, const fs::path& tgt, Exiv2::ImageType targe } if (Params::instance().target_ & Params::ctIptc && !sourceImage->iptcData().empty()) { if (Params::instance().verbose_ && !bStdout) { - std::cout << _("Writing IPTC data from") << " " << source << " " << _("to") << " " << target << '\n'; + std::cout << _("Writing IPTC data from") << " " << source.c_str() << " " << _("to") << " " << target.c_str() << '\n'; } if (preserve) { for (const auto& iptc : sourceImage->iptcData()) { @@ -1747,7 +1747,7 @@ int metacopy(const fs::path& source, const fs::path& tgt, Exiv2::ImageType targe } if (Params::instance().target_ & (Params::ctXmp | Params::ctXmpRaw) && !sourceImage->xmpData().empty()) { if (Params::instance().verbose_ && !bStdout) { - std::cout << _("Writing XMP data from") << " " << source << " " << _("to") << " " << target << '\n'; + std::cout << _("Writing XMP data from") << " " << source.c_str() << " " << _("to") << " " << target.c_str() << '\n'; } // #1148 use Raw XMP packet if there are no XMP modification commands @@ -1771,7 +1771,7 @@ int metacopy(const fs::path& source, const fs::path& tgt, Exiv2::ImageType targe } if (Params::instance().target_ & Params::ctComment && !sourceImage->comment().empty()) { if (Params::instance().verbose_ && !bStdout) { - std::cout << _("Writing JPEG comment from") << " " << source << " " << _("to") << " " << tgt << '\n'; + std::cout << _("Writing JPEG comment from") << " " << source.c_str() << " " << _("to") << " " << tgt << '\n'; } targetImage->setComment(sourceImage->comment()); } @@ -1780,7 +1780,7 @@ int metacopy(const fs::path& source, const fs::path& tgt, Exiv2::ImageType targe targetImage->writeMetadata(); rc = 0; } catch (const Exiv2::Error& e) { - std::cerr << tgt << ": " << _("Could not write metadata to file") << ": " << e << "\n"; + std::cerr << tgt.c_str() << ": " << _("Could not write metadata to file") << ": " << e << "\n"; rc = 1; } @@ -1829,7 +1829,7 @@ int renameFile(fs::path& newPath, const tm* tm) { const size_t max = 1024; char basename[max] = {}; if (strftime(basename, max, format.c_str(), tm) == 0) { - std::cerr << _("Filename format yields empty filename for the file") << " " << path << "\n"; + std::cerr << _("Filename format yields empty filename for the file") << " " << path.c_str() << "\n"; return 1; } @@ -1883,7 +1883,7 @@ int renameFile(fs::path& newPath, const tm* tm) { } if (Params::instance().verbose_) { - std::cout << _("Renaming file to") << " " << newPath; + std::cout << _("Renaming file to") << " " << newPath.c_str(); if (Params::instance().timestamp_) { std::cout << ", " << _("updating timestamp"); } @@ -1930,7 +1930,7 @@ std::ostream& operator<<(std::ostream& os, const std::pair& st int printStructure(std::ostream& out, Exiv2::PrintStructureOption option, const fs::path& path) { if (!Exiv2::fileExists(path)) { - std::cerr << path << ": " << _("Failed to open the file") << "\n"; + std::cerr << path.c_str() << ": " << _("Failed to open the file") << "\n"; return -1; } Exiv2::Image::UniquePtr image = Exiv2::ImageFactory::open(path);