File tree Expand file tree Collapse file tree 1 file changed +27
-1
lines changed Expand file tree Collapse file tree 1 file changed +27
-1
lines changed Original file line number Diff line number Diff line change @@ -95,6 +95,32 @@ int main(int argc, char **argv)
9595 return 1 ;
9696 }
9797
98+ // TODO: move this logic into simplecpp?
99+ {
100+ bool inc_missing = false ;
101+ for (const std::string& inc : dui.includes ) {
102+ std::fstream f (inc, std::ios::in|std::ios::out); // check if this is an existing file
103+ if (!f.is_open ()) {
104+ inc_missing = true ;
105+ std::cout << " error: could not open include '" << inc << " '" << std::endl;
106+ }
107+ }
108+ if (inc_missing)
109+ return 1 ;
110+ }
111+ {
112+ bool inc_missing = false ;
113+ for (const std::string& inc : dui.includePaths ) {
114+ struct stat file_stat;
115+ if ((stat (inc.c_str (), &file_stat) == -1 ) || ((file_stat.st_mode & S_IFMT) != S_IFDIR)) {
116+ inc_missing = true ;
117+ std::cout << " error: could not find include path '" << inc << " '" << std::endl;
118+ }
119+ }
120+ if (inc_missing)
121+ return 1 ;
122+ }
123+
98124 if (!filename) {
99125 std::cout << " Syntax:" << std::endl;
100126 std::cout << " simplecpp [options] filename" << std::endl;
@@ -117,7 +143,7 @@ int main(int argc, char **argv)
117143 std::vector<std::string> files;
118144 simplecpp::TokenList *rawtokens;
119145 if (use_istream) {
120- std::ifstream f (filename);
146+ std::ifstream f (filename, std::ios::in|std::ios::out );
121147 if (!f.is_open ()) {
122148 std::cout << " error: could not open file '" << filename << " '" << std::endl;
123149 return 1 ;
You can’t perform that action at this time.
0 commit comments