From 810f6e499b138cf399a030c25b7eedc76e7ad212 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Lars=20Gullik=20Bj=C3=B8nnes?= Date: Thu, 31 Aug 2006 19:32:12 +0000 Subject: [PATCH] Use exceptions to avoid more than one call to the filesystem. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@14857 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/insets/insetcite.C | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/insets/insetcite.C b/src/insets/insetcite.C index bcc8e1cd7d..7f02217480 100644 --- a/src/insets/insetcite.C +++ b/src/insets/insetcite.C @@ -27,6 +27,7 @@ #include "support/lstrings.h" #include +#include using lyx::support::ascii_lowercase; using lyx::support::contains; @@ -71,12 +72,19 @@ string const getNatbibLabel(Buffer const & buffer, for (vector::const_iterator it = bibfilesCache.begin(); it != bibfilesCache.end(); ++ it) { string const f = *it; - if (!fs::exists(f) || !fs::is_readable(fs::path(f).branch_path())) { - lyxerr << "Couldn't find or read bibtex file " << f << endl; - changed = true; - } else if (bibfileStatus[f] != fs::last_write_time(f)) { + try { + std::time_t lastw = fs::last_write_time(f); + if (lastw != bibfileStatus[f]) { + changed = true; + bibfileStatus[f] = lastw; + } + } + catch (fs::filesystem_error & fserr) { changed = true; - bibfileStatus[f] = fs::last_write_time(f); + lyxerr << "Couldn't find or read bibtex file " + << f << endl; + lyxerr[Debug::DEBUG] << "Fs error: " + << fserr.what() << endl; } } -- 2.39.5