[SCM] exiv2 packaging branch, master, updated. debian/0.25-3.1-3734-gdcbc29a
Maximiliano Curia
maxy at moszumanska.debian.org
Thu Jul 13 17:37:07 UTC 2017
Gitweb-URL: http://git.debian.org/?p=pkg-kde/kde-extras/exiv2.git;a=commitdiff;h=9b4cd05
The following commit has been merged in the master branch:
commit 9b4cd0590323756d26ca407b5c56e9b821fc6c88
Author: Andreas Huggel <ahuggel at gmx.net>
Date: Sun May 22 04:20:32 2005 +0000
Renaming files with the same timestamp: allow sequential numbering. Fixes bug #422
---
src/actions.cpp | 55 ++++++++++++++++++++++++++++++++++++++++++++++++-------
src/exiv2.cpp | 4 +++-
src/exiv2.hpp | 8 ++++++--
3 files changed, 57 insertions(+), 10 deletions(-)
diff --git a/src/actions.cpp b/src/actions.cpp
index 49001c5..5385c85 100644
--- a/src/actions.cpp
+++ b/src/actions.cpp
@@ -660,16 +660,57 @@ namespace Action {
}
return 0;
}
+
+ bool go = true;
+ int seq = 1;
+ std::string s;
+ Params::FileExistsPolicy fileExistsPolicy
+ = Params::instance().fileExistsPolicy_;
+ while (go) {
+ if (Exiv2::fileExists(newPath)) {
+ switch (fileExistsPolicy) {
+ case Params::overwritePolicy:
+ go = false;
+ break;
+ case Params::renamePolicy:
+ newPath = Util::dirname(path)
+ + EXV_SEPERATOR_STR + basename
+ + "_" + Exiv2::toString(seq++)
+ + Util::suffix(path);
+ break;
+ case Params::askPolicy:
+ std::cout << Params::instance().progname()
+ << ": File `" << newPath
+ << "' exists. [O]verwrite, [r]ename or [s]kip? ";
+ std::cin >> s;
+ switch (s[0]) {
+ case 'o':
+ case 'O':
+ go = false;
+ break;
+ case 'r':
+ case 'R':
+ fileExistsPolicy = Params::renamePolicy;
+ newPath = Util::dirname(path)
+ + EXV_SEPERATOR_STR + basename
+ + "_" + Exiv2::toString(seq++)
+ + Util::suffix(path);
+ break;
+ default: // skip
+ return 0;
+ break;
+ }
+ }
+ }
+ else {
+ go = false;
+ }
+ }
+
if (Params::instance().verbose_) {
std::cout << "Renaming file to " << newPath << std::endl;
}
- if (!Params::instance().force_ && Exiv2::fileExists(newPath)) {
- std::cout << Params::instance().progname()
- << ": Overwrite `" << newPath << "'? ";
- std::string s;
- std::cin >> s;
- if (s[0] != 'y' && s[0] != 'Y') return 0;
- }
+
// Workaround for MinGW rename which does not overwrite existing files
remove(newPath.c_str());
if (::rename(path.c_str(), newPath.c_str()) == -1) {
diff --git a/src/exiv2.cpp b/src/exiv2.cpp
index 575600d..65b2938 100644
--- a/src/exiv2.cpp
+++ b/src/exiv2.cpp
@@ -192,6 +192,7 @@ void Params::help(std::ostream& os) const
<< " -V Show the program version and exit.
"
<< " -v Be verbose during the program run.
"
<< " -f Do not prompt before overwriting existing files (force).
"
+ << " -F Do not prompt before renaming existing files (Force).
"
<< " -a time Time adjustment in the format [-]HH[:MM[:SS]]. This option
"
<< " is only used with the `adjust' action.
"
<< " -p mode Print mode for the `print' action. Possible modes are:
"
@@ -229,7 +230,8 @@ int Params::option(int opt, const std::string& optarg, int optopt)
case 'h': help_ = true; break;
case 'V': version_ = true; break;
case 'v': verbose_ = true; break;
- case 'f': force_ = true; break;
+ case 'f': force_ = true; fileExistsPolicy_ = overwritePolicy; break;
+ case 'F': force_ = true; fileExistsPolicy_ = renamePolicy; break;
case 'r': rc = evalRename(optarg); break;
case 'a': rc = evalAdjust(optarg); break;
case 'p': rc = evalPrint(optarg); break;
diff --git a/src/exiv2.hpp b/src/exiv2.hpp
index d6681f5..17d388c 100644
--- a/src/exiv2.hpp
+++ b/src/exiv2.hpp
@@ -124,12 +124,15 @@ public:
enum PrintMode { pmSummary, pmInterpreted, pmValues, pmHexdump, pmIptc,
pmComment };
//! Enumerates common targets, bitmap
- enum commonTarget { ctExif = 1, ctIptc = 2, ctComment = 4, ctThumb = 8 };
+ enum CommonTarget { ctExif = 1, ctIptc = 2, ctComment = 4, ctThumb = 8 };
+ //! Enumerates the policies to handle existing files in rename action
+ enum FileExistsPolicy { overwritePolicy, renamePolicy, askPolicy };
bool help_; //!< Help option flag.
bool version_; //!< Version option flag.
bool verbose_; //!< Verbose (talkative) option flag.
bool force_; //!< Force overwrites flag.
+ FileExistsPolicy fileExistsPolicy_; //!< What to do if file to rename exists.
bool adjust_; //!< Adjustment flag.
PrintMode printMode_; //!< Print mode.
//! %Action (integer rather than TaskType to avoid dependency).
@@ -149,11 +152,12 @@ private:
@brief Default constructor. Note that optstring_ is initialized here.
The c'tor is private to force instantiation through instance().
*/
- Params() : optstring_(":hVvfa:r:p:d:e:i:m:M:l:"),
+ Params() : optstring_(":hVvfFa:r:p:d:e:i:m:M:l:"),
help_(false),
version_(false),
verbose_(false),
force_(false),
+ fileExistsPolicy_(askPolicy),
adjust_(false),
printMode_(pmSummary),
action_(0),
--
exiv2 packaging
More information about the pkg-kde-commits
mailing list