diff --git a/src/actions.cpp b/src/actions.cpp index a9e30fe3..e61fa9bf 100644 --- a/src/actions.cpp +++ b/src/actions.cpp @@ -960,8 +960,10 @@ namespace Action { || Params::instance().target_ & Params::ctComment) { std::string directory = Params::instance().directory_; if (directory.empty()) directory = Util::dirname(path); + std::string suffix = Params::instance().suffix_; + if (suffix.empty()) suffix = "exv"; std::string exvPath = directory + EXV_SEPERATOR_STR - + Util::basename(path, true) + ".exv"; + + Util::basename(path, true) + "." + suffix; rc = metacopy(exvPath, path, true); } return rc; diff --git a/src/exiv2.cpp b/src/exiv2.cpp index c97e069b..b9ca5191 100644 --- a/src/exiv2.cpp +++ b/src/exiv2.cpp @@ -230,7 +230,8 @@ void Params::help(std::ostream& os) const << " set|add|del [[] ].\n" << " -M cmd Command line for the modify action. The format for the\n" << " commands is the same as that of the lines of a command file.\n" - << " -l dir Location (directory) for files to be inserted or extracted.\n\n"; + << " -l dir Location (directory) for files to be inserted from or extracted to.\n" + << " -s ext Suffix of the files to be inserted from.\n\n"; } // Params::help int Params::option(int opt, const std::string& optarg, int optopt) @@ -251,6 +252,7 @@ int Params::option(int opt, const std::string& optarg, int optopt) case 'm': rc = evalModify(opt, optarg); break; case 'M': rc = evalModify(opt, optarg); break; case 'l': directory_ = optarg; break; + case 's': suffix_ = optarg; break; case ':': std::cerr << progname() << ": Option -" << static_cast(optopt) << " requires an argument\n"; @@ -572,10 +574,17 @@ int Params::getopt(int argc, char* const argv[]) rc = 1; } } - if (!directory_.empty() && !(action_ == Action::insert || action_ == Action::extract)) { - std::cerr << progname() << ": -l option can only be used with extract or insert actions\n"; + if ( !directory_.empty() + && !(action_ == Action::insert || action_ == Action::extract)) { + std::cerr << progname() + << ": -l option can only be used with extract or insert actions\n"; rc = 1; } + if (!suffix_.empty() && !action_ == Action::insert) { + std::cerr << progname() + << ": -s option can only be used with insert action\n"; + rc = 1; + } return rc; } // Params::getopt diff --git a/src/exiv2.hpp b/src/exiv2.hpp index dbdbc1a4..836ec211 100644 --- a/src/exiv2.hpp +++ b/src/exiv2.hpp @@ -147,6 +147,7 @@ public: CmdLines cmdLines_; //!< Commands from the command line ModifyCmds modifyCmds_; //!< Parsed modification commands std::string directory_; //!< Location for files to extract/insert + std::string suffix_; //!< File extension of the file to insert Files files_; //!< List of non-option arguments. private: @@ -154,7 +155,7 @@ private: @brief Default constructor. Note that optstring_ is initialized here. The c'tor is private to force instantiation through instance(). */ - Params() : optstring_(":hVvfFa:r:p:d:e:i:m:M:l:"), + Params() : optstring_(":hVvfFa:r:p:d:e:i:m:M:l:s:"), help_(false), version_(false), verbose_(false), diff --git a/test/data/exiv2-test.out b/test/data/exiv2-test.out index cfa5c368..1f07cb87 100644 --- a/test/data/exiv2-test.out +++ b/test/data/exiv2-test.out @@ -57,7 +57,8 @@ Options: set|add|del [[] ]. -M cmd Command line for the modify action. The format for the commands is the same as that of the lines of a command file. - -l dir Location (directory) for files to be inserted or extracted. + -l dir Location (directory) for files to be inserted from or extracted to. + -s ext Suffix of the files to be inserted from. Adjust -------------------------------------------------------------------