+namespace {
+
+void handleFoundFile(string const & ff, DepTable & head)
+{
+ // convert from native os path to unix path
+ string const foundfile = os::internal_path(trim(ff));
+
+ lyxerr[Debug::DEPEND] << "Found file: " << foundfile << endl;
+
+ // Ok now we found a file.
+ // Now we should make sure that this is a file that we can
+ // access through the normal paths.
+ // We will not try any fancy search methods to
+ // find the file.
+
+ // (1) foundfile is an
+ // absolute path and should
+ // be inserted.
+ if (AbsolutePath(foundfile)) {
+ lyxerr[Debug::DEPEND] << "AbsolutePath file: "
+ << foundfile << endl;
+ // On initial insert we want to do the update at once
+ // since this file can not be a file generated by
+ // the latex run.
+ if (FileInfo(foundfile).exist())
+ head.insert(foundfile, true);
+
+ return;
+ }
+
+ string const onlyfile = OnlyFilename(foundfile);
+
+ // (2) foundfile is in the tmpdir
+ // insert it into head
+ if (FileInfo(onlyfile).exist()) {
+ static regex unwanted("^.*\\.(aux|log|dvi|bbl|ind|glo)$");
+ if (regex_match(onlyfile, unwanted)) {
+ lyxerr[Debug::DEPEND]
+ << "We don't want "
+ << onlyfile
+ << " in the dep file"
+ << endl;
+ } else if (suffixIs(onlyfile, ".tex")) {
+ // This is a tex file generated by LyX
+ // and latex is not likely to change this
+ // during its runs.
+ lyxerr[Debug::DEPEND]
+ << "Tmpdir TeX file: "
+ << onlyfile
+ << endl;
+ head.insert(onlyfile, true);
+ } else {
+ lyxerr[Debug::DEPEND]
+ << "In tmpdir file:"
+ << onlyfile
+ << endl;
+ head.insert(onlyfile);
+ }
+ } else
+ lyxerr[Debug::DEPEND]
+ << "Not a file or we are unable to find it."
+ << endl;
+}
+
+} // anon namespace
+
+