Added -s <suffix> option to the utility. This allows, e.g, to use Canon THM files as source file for the insert command.

v0.27.3
Andreas Huggel 20 years ago
parent 2b55ed40b6
commit d7c80de351

@ -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;

@ -230,7 +230,8 @@ void Params::help(std::ostream& os) const
<< " set|add|del <key> [[<type>] <value>].\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<char>(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

@ -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),

@ -57,7 +57,8 @@ Options:
set|add|del <key> [[<type>] <value>].
-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 -------------------------------------------------------------------

Loading…
Cancel
Save