X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Fsupport%2FFileMonitor.C;h=715c10f569fa0b09af421c480b4eecc802224dd8;hb=c8429d4bbc2e9291a6b5742233aecb089a3eece1;hp=c96b4e6233dfe8c4f6675b295749d5ef67b8de6c;hpb=92d522b7f1be6046adcac062c558bbf0bf021612;p=lyx.git diff --git a/src/support/FileMonitor.C b/src/support/FileMonitor.C index c96b4e6233..715c10f569 100644 --- a/src/support/FileMonitor.C +++ b/src/support/FileMonitor.C @@ -5,25 +5,31 @@ * * \author Angus Leeming * - * Full author contact details are available in file CREDITS + * Full author contact details are available in file CREDITS. */ #include -#include "FileMonitor.h" +#include "support/FileMonitor.h" +#include "support/lyxlib.h" +// FIXME Interface violation #include "frontends/Timeout.h" -#include "support/FileInfo.h" -#include "support/lyxlib.h" - #include +#include #include + +using std::string; + +namespace fs = boost::filesystem; + namespace lyx { namespace support { -struct FileMonitor::Impl : public boost::signals::trackable { +class FileMonitor::Impl : public boost::signals::trackable { +public: /// Impl(string const & file_with_path, int interval); @@ -38,7 +44,7 @@ struct FileMonitor::Impl : public boost::signals::trackable { Timeout timer_; /// This signal is emitted if the file is modified (has a new checksum). - boost::signal0 fileChanged_; + FileMonitor::FileChangedSig fileChanged_; /** We use these to ascertain whether a file (once loaded successfully) * has changed. @@ -85,11 +91,10 @@ void FileMonitor::start() const if (monitoring()) return; - FileInfo finfo(pimpl_->filename_); - if (!finfo.isOK()) + if (!fs::exists(pimpl_->filename_)) return; - pimpl_->timestamp_ = finfo.getModificationTime(); + pimpl_->timestamp_ = fs::last_write_time(pimpl_->filename_); pimpl_->checksum_ = sum(pimpl_->filename_); if (pimpl_->timestamp_ && pimpl_->checksum_) { @@ -151,14 +156,13 @@ void FileMonitor::Impl::monitorFile() { bool changed = false; - FileInfo finfo(filename_); - if (!finfo.isOK()) { + if (!fs::exists(filename_)) { changed = timestamp_ || checksum_; timestamp_ = 0; checksum_ = 0; } else { - time_t const new_timestamp = finfo.getModificationTime(); + time_t const new_timestamp = fs::last_write_time(filename_); if (new_timestamp != timestamp_) { timestamp_ = new_timestamp;