Improve fix for bug 3305

* src/LaTeX.C
	(insertIfExists): Instead of catching all fs exceptions, test for a
	valid filename before constructing a fs::path. This gets rid of the
	exceptions because of invalid names, but does still allow other
	expcetions to be thrown (e.g. because of file system problems).
	(handleFoundFile): ditto


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@17424 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Georg Baum 2007-03-12 19:38:20 +00:00
parent 5a90cc6871
commit 52727f6f96

View File

@ -758,18 +758,14 @@ namespace {
bool insertIfExists(FileName const & absname, DepTable & head) bool insertIfExists(FileName const & absname, DepTable & head)
{ {
bool exists; // fs::path may throw an exception if absname is too strange
try { if (!fs::native(absname.toFilesystemEncoding())) {
fs::path const path = absname.toFilesystemEncoding(); lyxerr[Debug::DEPEND] << '`' << absname.absFilename()
exists = fs::exists(path) && !fs::is_directory(path); << "' is no valid file name." << endl;
return false;
} }
catch (fs::filesystem_error const & fe) { fs::path const path(absname.toFilesystemEncoding());
// This was probably no file at all. if (fs::exists(path) && !fs::is_directory(path)) {
lyxerr[Debug::DEPEND] << "Got error `" << fe.what()
<< "' while checking whether file `" << absname
<< "' exists and is no directory." << endl;
}
if (exists) {
head.insert(absname, true); head.insert(absname, true);
return true; return true;
} }
@ -820,15 +816,13 @@ bool handleFoundFile(string const & ff, DepTable & head)
// check for spaces // check for spaces
while (contains(foundfile, ' ')) { while (contains(foundfile, ' ')) {
bool exists; // fs::path may throw an exception if absname is too strange
try { bool exists = fs::native(absname.toFilesystemEncoding());
if (exists)
exists = fs::exists(absname.toFilesystemEncoding()); exists = fs::exists(absname.toFilesystemEncoding());
} else {
catch (fs::filesystem_error const & fe) { lyxerr[Debug::DEPEND] << '`' << absname.absFilename()
// This was probably no file at all. << "' is no valid file name." << endl;
lyxerr[Debug::DEPEND] << "Got error `" << fe.what()
<< "' while checking whether file `"
<< absname << "' exists." << endl;
} }
if (exists) if (exists)
// everything o.k. // everything o.k.
@ -846,16 +840,14 @@ bool handleFoundFile(string const & ff, DepTable & head)
// (2) foundfile is in the tmpdir // (2) foundfile is in the tmpdir
// insert it into head // insert it into head
bool exists; // fs::path may throw an exception if absname is too strange
try { bool exists = fs::native(absname.toFilesystemEncoding());
if (exists) {
fs::path const path = absname.toFilesystemEncoding(); fs::path const path = absname.toFilesystemEncoding();
exists = fs::exists(path) && !fs::is_directory(path); exists = fs::exists(path) && !fs::is_directory(path);
} } else {
catch (fs::filesystem_error const & fe) { lyxerr[Debug::DEPEND] << '`' << absname.absFilename()
// This was probably no file at all. << "' is no valid file name." << endl;
lyxerr[Debug::DEPEND] << "Got error `" << fe.what()
<< "' while checking whether file `" << absname
<< "' exists and is no directory." << endl;
} }
if (exists) { if (exists) {
static regex unwanted("^.*\\.(aux|log|dvi|bbl|ind|glo)$"); static regex unwanted("^.*\\.(aux|log|dvi|bbl|ind|glo)$");