28 #ifdef HAVE_SYS_INOTIFY_H
29 #include <sys/inotify.h>
50 #ifdef HAVE_SYS_INOTIFY_H
63 #ifdef HAVE_SYS_INOTIFY_H
64 for (watch_map::iterator iter = _watch_map.begin(); iter != _watch_map.end(); ++iter)
66 const int wd = (*iter).first;
67 inotify_rm_watch(this->
fd(), wd);
79 #ifdef HAVE_SYS_INOTIFY_H
80 int wd = inotify_add_watch(this->fd(), path.getPath().c_str(), opts);
81 _watch_map[wd] = path;
87 #ifdef HAVE_SYS_INOTIFY_H
88 return ::read(this->fd(), data, len);
112 if (socks.size() == 0)
return;
115 #ifdef HAVE_SYS_INOTIFY_H
116 sock.
watch(watch, IN_CREATE | IN_DELETE);
118 _watchset.insert(watch);
133 #ifdef HAVE_SYS_INOTIFY_H
145 _socket.
select(&fds, NULL, NULL, NULL);
148 for (ibrcommon::socketset::iterator iter = fds.begin(); iter != fds.end(); ++iter)
151 sock.
read((
char*)&buf, 1024);
176 void FileMonitor::scan()
180 std::set<ibrcommon::File> watch_set;
182 for (watch_set::iterator iter = _watchset.begin(); iter != _watchset.end(); ++iter)
185 std::list<ibrcommon::File> files;
189 for (std::list<ibrcommon::File>::iterator iter = files.begin(); iter != files.end(); ++iter)
191 watch_set.insert(*iter);
201 for (std::set<ibrcommon::File>::iterator iter = watch_set.begin(); iter != watch_set.end(); ++iter)
206 if (!isActive(path)) {
213 for (std::map<ibrcommon::File, dtn::core::Node>::iterator iter = _active_paths.begin(); iter != _active_paths.end();)
218 if (watch_set.find(path) == watch_set.end())
222 _active_paths.erase(iter++);
243 const std::string uri =
"file://" + path.
getPath() +
"/" + cf.read<std::string>(
"PATH");
248 _active_paths[path] = n;
258 return (_active_paths.find(path) != _active_paths.end());
263 return "FileMonitor";