FileWatcher.h
Go to the documentation of this file.
1 #ifndef FILEWATCHER__H
2 #define FILEWATCHER__H
3 #include <boost/filesystem.hpp>
5 #include <string>
6 
7 class FileWatcher{
8  public:
10 
12 
13  void setPath(const std::string& p){_path=p; update();}
14 
15  bool isModified(){return(_last_time < get_time());}
16 
17  std::time_t get_time(){
18  if(!boost::filesystem::exists(_path)){
19  mf::LogWarning("FileWatcher")<<" file \""<<_path<<"\" does not exist."
20  <<" Waiting until it is created..."<<std::endl;
21  return 0;
22  }
23  else
24  return boost::filesystem::last_write_time(_path);
25  }
26 
27  void update(){ _last_time=get_time(); }
28  protected:
30  std::time_t _last_time;
31 };
32 
33 #endif
bool isModified()
Definition: FileWatcher.h:15
void update()
Definition: FileWatcher.h:27
const char * p
Definition: xmltok.h:285
FileWatcher(const std::string &p)
Definition: FileWatcher.h:11
void setPath(const std::string &p)
Definition: FileWatcher.h:13
const std::string path
Definition: plot_BEN.C:43
std::time_t get_time()
Definition: FileWatcher.h:17
std::time_t _last_time
Definition: FileWatcher.h:30
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
boost::filesystem::path _path
Definition: FileWatcher.h:29
enum BeamMode string