#include <vector>
we expect that either (i) make_dependencies ignores this dependence
because it can't find the file <vector> anywhere, e.g. because it
doesn't know the path to system header files, or (ii) enter the proper
dependency to the file if it does know where to find the file.
But what happened in the tests/serialization directory is that it
found a *subdirectory* named 'vector' and added it to the list of
dependencies. And 'make' then tries to re-build this directory by
compiling (using an implicit rule built into 'make') the executable
'vector' from 'vector.cc', which fails because the implicit rule of
course doesn't know anything about where deal.II include files reside,
etc. Completely strange.
So the solution is to ignore directories, if we happen to find
them. In the process, I also replaced the use of std::istream to
test-open a file (which weirdly succeeds for directories, although you
can't read from it) by uses of stat(), which should be faster as well.
git-svn-id: https://svn.dealii.org/trunk@22940
0785d39b-7218-0410-832d-
ea1e28bc413d
#include <vector>
#include <cassert>
#include <cstdlib>
+#include <sys/stat.h>
// base path for object files,
// including trailing slash if
for (std::vector<std::string>::const_iterator
include_dir=include_directories.begin();
include_dir!=include_directories.end(); ++include_dir)
- if (std::ifstream((*include_dir+included_file).c_str()))
- {
- included_file = *include_dir+included_file;
- break;
- }
+ {
+ struct stat buf;
+ int error = stat ((*include_dir+included_file).c_str(), &buf);
+
+ if ((error == 0) &&
+ S_ISREG(buf.st_mode))
+ {
+ included_file = *include_dir+included_file;
+ break;
+ }
+ }
}
- // make sure the file
- // exists, otherwise just
- // ignore the line
- if (!std::ifstream(included_file.c_str()))
- continue;
+ // make sure the file exists
+ // and that we can read from
+ // it, otherwise just ignore
+ // the line
+ {
+ struct stat buf;
+ int error = stat (included_file.c_str(), &buf);
+
+ if ((error != 0) ||
+ !S_ISREG(buf.st_mode))
+ continue;
+ }
+
+
// ok, so we did find an
// appropriate file. add it to