X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Fsupport%2FFileMonitor.cpp;h=9f959d5a3a5bac557917ab38f1bbf758cb8c1ea8;hb=b60b505fd82866dc57d4522b3ff73ae5bd337612;hp=039d9a8978b3bd09ec488077ef954d8949f7b780;hpb=f212b483355d68e93132fb469814e13335d0886b;p=lyx.git diff --git a/src/support/FileMonitor.cpp b/src/support/FileMonitor.cpp index 039d9a8978..9f959d5a3a 100644 --- a/src/support/FileMonitor.cpp +++ b/src/support/FileMonitor.cpp @@ -11,20 +11,14 @@ #include #include "support/FileMonitor.h" -#include "support/FileName.h" -#include "support/lyxlib.h" -// FIXME Interface violation -#include "frontends/Timeout.h" +#include "support/FileName.h" +#include "support/Timeout.h" -#include -#include +#include "support/bind.h" #include - -using std::string; - -namespace fs = boost::filesystem; +using namespace std; namespace lyx { namespace support { @@ -62,7 +56,9 @@ FileMonitor::FileMonitor(FileName const & file_with_path, int interval) FileMonitor::~FileMonitor() -{} +{ + delete pimpl_; +} void FileMonitor::reset(FileName const & file_with_path) const @@ -92,11 +88,11 @@ void FileMonitor::start() const if (monitoring()) return; - if (!fs::exists(pimpl_->filename_.toFilesystemEncoding())) + if (!pimpl_->filename_.exists()) return; - pimpl_->timestamp_ = fs::last_write_time(pimpl_->filename_.toFilesystemEncoding()); - pimpl_->checksum_ = sum(pimpl_->filename_); + pimpl_->timestamp_ = pimpl_->filename_.lastModified(); + pimpl_->checksum_ = pimpl_->filename_.checksum(); if (pimpl_->timestamp_ && pimpl_->checksum_) { pimpl_->timer_.start(); @@ -126,7 +122,7 @@ unsigned long FileMonitor::checksum() const // If we aren't actively monitoring the file, then recompute the // checksum explicitly. if (!pimpl_->timer_.running() && !pimpl_->filename_.empty()) - return sum(pimpl_->filename_); + return pimpl_->filename_.checksum(); return pimpl_->checksum_; } @@ -149,7 +145,7 @@ FileMonitor::Impl::Impl(FileName const & file_with_path, int interval) timestamp_(0), checksum_(0) { - timer_.timeout.connect(boost::bind(&Impl::monitorFile, this)); + timer_.timeout.connect(bind(&Impl::monitorFile, this)); } @@ -157,18 +153,18 @@ void FileMonitor::Impl::monitorFile() { bool changed = false; - if (!fs::exists(filename_.toFilesystemEncoding())) { + if (!filename_.exists()) { changed = timestamp_ || checksum_; timestamp_ = 0; checksum_ = 0; } else { - time_t const new_timestamp = fs::last_write_time(filename_.toFilesystemEncoding()); + time_t const new_timestamp = filename_.lastModified(); if (new_timestamp != timestamp_) { timestamp_ = new_timestamp; - unsigned long const new_checksum = sum(filename_); + unsigned long const new_checksum = filename_.checksum(); if (new_checksum != checksum_) { checksum_ = new_checksum; changed = true;