Skip to content

Commit

Permalink
checking input a bit better
Browse files Browse the repository at this point in the history
  • Loading branch information
Stefan Jaud committed Apr 25, 2021
1 parent 5ee2902 commit 2dad059
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions UnitTests/Utilities/ScreenShotMaker/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,20 +167,18 @@ int main(int argc, char **argv) {
const char* filepath = sourceFiles.getValue().c_str();
std::string outputDirectoryName = outputDirectory.getValue();

// check input
boost::filesystem::path givenPathToFile(filepath);
if (!boost::filesystem::exists(givenPathToFile))
throw std::exception("Provided IFC file does not exist.");
if (!boost::filesystem::exists(outputDirectoryName))
throw std::exception("Provided output directory does not exist.");

std::cout << "Generating screen shots from " << std::endl;
std::cout << filepath << std::endl;
std::cout << "Saving screen shots to " << std::endl;
std::cout << outputDirectoryName << std::endl;

FILE *myfile = fopen(filepath, "r");
// make sure it is valid:
if (!myfile) {
std::string err = std::string("I can't open file ") + std::string(filepath) + std::string("!");
throw std::exception(err.c_str());
}
fclose(myfile);

boost::filesystem::path givenPathToFile(filepath);
std::string filename = givenPathToFile.stem().string();
std::string filetype = givenPathToFile.extension().string();
std::transform(filetype.begin(), filetype.end(), filetype.begin(), ::tolower);
Expand Down

0 comments on commit 2dad059

Please sign in to comment.