mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-27 11:52:25 +00:00
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
This commit is contained in:
parent
74344a8f4b
commit
810f6e499b
@ -27,6 +27,7 @@
|
|||||||
#include "support/lstrings.h"
|
#include "support/lstrings.h"
|
||||||
|
|
||||||
#include <boost/filesystem/operations.hpp>
|
#include <boost/filesystem/operations.hpp>
|
||||||
|
#include <boost/filesystem/exception.hpp>
|
||||||
|
|
||||||
using lyx::support::ascii_lowercase;
|
using lyx::support::ascii_lowercase;
|
||||||
using lyx::support::contains;
|
using lyx::support::contains;
|
||||||
@ -71,12 +72,19 @@ string const getNatbibLabel(Buffer const & buffer,
|
|||||||
for (vector<string>::const_iterator it = bibfilesCache.begin();
|
for (vector<string>::const_iterator it = bibfilesCache.begin();
|
||||||
it != bibfilesCache.end(); ++ it) {
|
it != bibfilesCache.end(); ++ it) {
|
||||||
string const f = *it;
|
string const f = *it;
|
||||||
if (!fs::exists(f) || !fs::is_readable(fs::path(f).branch_path())) {
|
try {
|
||||||
lyxerr << "Couldn't find or read bibtex file " << f << endl;
|
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;
|
changed = true;
|
||||||
} else if (bibfileStatus[f] != fs::last_write_time(f)) {
|
lyxerr << "Couldn't find or read bibtex file "
|
||||||
changed = true;
|
<< f << endl;
|
||||||
bibfileStatus[f] = fs::last_write_time(f);
|
lyxerr[Debug::DEBUG] << "Fs error: "
|
||||||
|
<< fserr.what() << endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user