summaryrefslogtreecommitdiff
path: root/tools/scaninc/scaninc.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tools/scaninc/scaninc.cpp')
-rw-r--r--tools/scaninc/scaninc.cpp15
1 files changed, 14 insertions, 1 deletions
diff --git a/tools/scaninc/scaninc.cpp b/tools/scaninc/scaninc.cpp
index 803355f32..9a228180a 100644
--- a/tools/scaninc/scaninc.cpp
+++ b/tools/scaninc/scaninc.cpp
@@ -276,6 +276,17 @@ void AsmFile::SkipString()
}
}
+bool CanOpenFile(std::string path)
+{
+ FILE *fp = fopen(path.c_str(), "rb");
+
+ if (fp == NULL)
+ return false;
+
+ fclose(fp);
+ return true;
+}
+
int main(int argc, char **argv)
{
if (argc < 2)
@@ -296,7 +307,9 @@ int main(int argc, char **argv)
while ((incDirectiveType = file.ReadUntilIncDirective(path)) != IncDirectiveType::None) {
bool inserted = dependencies.insert(path).second;
- if (inserted && incDirectiveType == IncDirectiveType::Include)
+ if (inserted
+ && incDirectiveType == IncDirectiveType::Include
+ && CanOpenFile(path))
filesToProcess.push(path);
}
}