File tree Expand file tree Collapse file tree 1 file changed +28
-1
lines changed Expand file tree Collapse file tree 1 file changed +28
-1
lines changed Original file line number Diff line number Diff line change 99#include < cstring>
1010#include < fstream>
1111#include < iostream>
12+ #include < sys/stat.h>
1213#include < string>
1314#include < vector>
1415
@@ -95,6 +96,32 @@ int main(int argc, char **argv)
9596 return 1 ;
9697 }
9798
99+ // TODO: move this logic into simplecpp?
100+ {
101+ bool inc_missing = false ;
102+ for (const std::string& inc : dui.includes ) {
103+ std::fstream f (inc, std::ios::in|std::ios::out); // check if this is an existing file
104+ if (!f.is_open ()) {
105+ inc_missing = true ;
106+ std::cout << " error: could not open include '" << inc << " '" << std::endl;
107+ }
108+ }
109+ if (inc_missing)
110+ return 1 ;
111+ }
112+ {
113+ bool inc_missing = false ;
114+ for (const std::string& inc : dui.includePaths ) {
115+ struct stat file_stat;
116+ if ((stat (inc.c_str (), &file_stat) == -1 ) || ((file_stat.st_mode & S_IFMT) != S_IFDIR)) {
117+ inc_missing = true ;
118+ std::cout << " error: could not find include path '" << inc << " '" << std::endl;
119+ }
120+ }
121+ if (inc_missing)
122+ return 1 ;
123+ }
124+
98125 if (!filename) {
99126 std::cout << " Syntax:" << std::endl;
100127 std::cout << " simplecpp [options] filename" << std::endl;
@@ -117,7 +144,7 @@ int main(int argc, char **argv)
117144 std::vector<std::string> files;
118145 simplecpp::TokenList *rawtokens;
119146 if (use_istream) {
120- std::ifstream f (filename);
147+ std::ifstream f (filename, std::ios::in|std::ios::out );
121148 if (!f.is_open ()) {
122149 std::cout << " error: could not open file '" << filename << " '" << std::endl;
123150 return 1 ;
You can’t perform that action at this time.
0 commit comments