Skip to content

Commit

Permalink
Merge pull request jackwadden#8 from knightofions/master
Browse files Browse the repository at this point in the history
Merge test trial jackwadden#2. This code adds an error message to the instance that a supplied input file cannot be found.
  • Loading branch information
jackwadden committed Jun 17, 2016
2 parents c9bf02e + bdfa5ae commit fdc4f2d
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/main.cpp
Expand Up @@ -8,6 +8,7 @@
#include <chrono>
#include <ctime>
#include <thread>
#include "errno.h"

#define FROM_INPUT_STRING false

Expand Down Expand Up @@ -58,11 +59,19 @@ uint32_t fileSize(string fn) {

return fileSize;
}

void inputFileCheck() {
if(errno == ENOENT) {
cout<< "VAsim Error: no such input file." << endl;
exit(-1);
}
}
vector<unsigned char> file2CharVector(string fn) {

// open the file:
std::ifstream file(fn, ios::binary);
if(file.fail()){
inputFileCheck();
}

// get its size:
std::streampos fileSize;
Expand Down

0 comments on commit fdc4f2d

Please sign in to comment.