Browse Source

Add a command-line option for the output directory

coverity_scan
Daniel Scharrer 13 years ago
parent
commit
fbc214843d
  1. 4
      README.md
  2. 12
      doc/innoextract.1
  3. 24
      src/cli/main.cpp

4
README.md

@ -86,11 +86,11 @@ Documentation is also available as a man page:
* Included scripts and checks are not executed.
* Data is always extracted to the current directory and the mapping from Inno Setup variables like the application directory to subdirectories is hard-coded.
* The mapping from Inno Setup variables like the application directory to subdirectories is hard-coded.
* innoextract does not check if an installer includes multiple files with the same name and will continually overwrite the destination file when extracting.
* Names for data files in multi-file installers must follow the standard naming scheme.
* Names for data slice/disk files in multi-file installers must follow the standard naming scheme.
* Encrypted installers are not supported.

12
doc/innoextract.1

@ -36,15 +36,16 @@ Here is a short summary of the options available in innoextract. Please refer to
\-l \-\-list Only list files, don't write anything
.fi
.TP
.B Filters:
.B Modifiers:
.nf
\-\-dump Dump contents without converting filenames
\-L \-\-lowercase Convert extracted filenames to lower-case
\-\-language=LANG Extract files for the given language
\-T \-\-timestamps=TZ Timezone for file times or "local" or "none"
\-d \-\-output-dir=DIR Extract files into the given directory
.fi
.TP
.B I/O options:
.B Display options:
.nf
\-q \-\-quiet Output less information
\-s \-\-silent Output only error/warning information
@ -83,6 +84,11 @@ The \fB--list\fP option can be combined with \fB--test\fP or \fB--extract\fP to
\fB-L\fP, \fB--lowercase\fP
Convert filenames stored in the installer to lower-case before extracting.
.TP
\fB-d\fP, \fB--output-dir\fP=DIR
Extract all files into the given directory. By default, \fBinnoextract\fP will extract all files to the current directory.
If the specified directory does not exist, it will be created. However, the parent directory must exist or extracting will fail.
.TP
\fB-p\fP, \fB--progress\fP[=ENABLE]
By default \fBinnoextract\fP will try to detect if the terminal supports shell escape codes and enable or disable progress bar output accordingly. Pass \fB1\fP or \fBtrue\fP to \fB--progress\fP to force progress bar output. Pass \fB0\fP or \fBfalse\fP to never show a progress bar.
.TP
@ -123,7 +129,7 @@ Success
.IP \fB1\fP
Syntax or usage error
.IP \fB2+\fP
Broken or unsupported setup file
Broken or unsupported setup file, or input/output error
.SH LIMITATIONS
\fBinnoextract\fP currently only supports extracting all the data. There is no support for extracting individual files or components and limited support for extracting language-specific files.

24
src/cli/main.cpp

@ -117,6 +117,8 @@ struct options {
setup::filename_map filenames;
fs::path output_dir;
};
@ -375,7 +377,7 @@ static void process_file(const fs::path & file, const options & o) {
if(!o.test) {
output.reserve(output_names.size());
BOOST_FOREACH(const file_t & path, output_names) {
output.push_back(new file_output(path.first));
output.push_back(new file_output(o.output_dir / path.first));
}
}
@ -445,15 +447,16 @@ int main(int argc, char * argv[]) {
("list,l", "Only list files, don't write anything")
;
po::options_description filter("Filters");
po::options_description filter("Modifiers");
filter.add_options()
("dump", "Dump contents without converting filenames")
("lowercase,L", "Convert extracted filenames to lower-case")
("language", po::value<std::string>(), "Extract files for the given language")
("timestamps,T", po::value<std::string>(), "Timezone for file times or \"local\" or \"none\"")
("output-dir,d", po::value<fs::path>(), "Extract files into the given directory")
;
po::options_description io("I/O options");
po::options_description io("Display options");
io.add_options()
("quiet,q", "Output less information")
("silent,s", "Output only error/warning information")
@ -590,6 +593,21 @@ int main(int argc, char * argv[]) {
return ExitSuccess;
}
{
po::variables_map::const_iterator i = options.find("output-dir");
if(i != options.end()) {
o.output_dir = i->second.as<fs::path>();
if(!fs::exists(o.output_dir)) {
try {
fs::create_directory(o.output_dir);
} catch(...) {
log_error << "could not create output directory " << o.output_dir;
return ExitDataError;
}
}
}
}
const std::vector<std::string> & files = options["setup-files"]
.as< std::vector<std::string> >();

Loading…
Cancel
Save