Skip to content

Commit

Permalink
TOOLS: Make input files handling more robust
Browse files Browse the repository at this point in the history
Some tools have a very generic input file format (e.g. *.*) but
reimplement inspectInput() to restrict the acceptable inputs.
However this was only used when working out which tool can
process a given input (when the tool is not specified). Now this
is also used when checking the inputs given to a specific tool.
  • Loading branch information
criezy committed Oct 20, 2014
1 parent 1bc845f commit 6f89394
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions tool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,12 @@ void Tool::clearInputPaths() {
}

bool Tool::addInputPath(const std::string& in) {
// Check the input is acceptable. Usually this is done when calling inspectInput(filename, format),
// but inspectInput(filename) might be reimplemented to be more restrictive (especially when the
// format is "*.*").
if (inspectInput(in) == IMATCH_AWFUL)
return false;
// Now we know it matches. Look for the best match.
int bestMatchIndex = -1;
InspectionMatch bestMatch = IMATCH_AWFUL;
for (ToolInputs::iterator iter = _inputPaths.begin(); iter != _inputPaths.end(); ++iter) {
Expand Down

0 comments on commit 6f89394

Please sign in to comment.