]> git.tdb.fi Git - libs/core.git/blob - source/fs/filemonitor.cpp
Add a few missing default initializers
[libs/core.git] / source / fs / filemonitor.cpp
1 #include <msp/core/algorithm.h>
2 #include <msp/core/except.h>
3 #include "filemonitor.h"
4 #include "filemonitor_platform.h"
5
6 using namespace std;
7
8 namespace Msp {
9 namespace FS {
10
11 FileMonitor::FileMonitor():
12         priv(new Private(*this))
13 { }
14
15 FileMonitor::~FileMonitor()
16 {
17         delete priv;
18 }
19
20 void FileMonitor::use_event_dispatcher(IO::EventDispatcher &ed)
21 {
22         if(event_disp)
23                 throw already_called("FileMonitor::use_event_dispatcher");
24
25         event_disp = &ed;
26         platform_use_event_dispatcher();
27 }
28
29 void FileMonitor::add_file(const FS::Path &path)
30 {
31         MonitoredFile file;
32         file.path = path;
33         prepare_file(file);
34         files.push_back(file);
35 }
36
37 void FileMonitor::remove_file(const FS::Path &path)
38 {
39         auto i = find_member(files, path, &MonitoredFile::path);
40         if(i!=files.end())
41         {
42                 cleanup_file(*i);
43                 if(&*i!=&files.back())
44                         *i = files.back();
45                 files.pop_back();
46         }
47 }
48
49 } // namespace FS
50 } // namespace Msp