29 #include <sys/inotify.h>
62 INFO(
"inotify start");
73 if (inotify_rm_watch(
_inotifyFd, watch.first) == -1)
82 std::uint32_t mask = IN_CLOSE_WRITE;
86 if ((watch = inotify_add_watch(
_inotifyFd, path.c_str(), mask)) == -1)
97 if (param.second.path == path)
98 return ((param.second.mask & IN_CLOSE_WRITE) > 0);
100 throw(
FsException(
"no registered watch for path:" + path));
107 if (param.second.path == path)
109 param.second.mask = 0;
113 throw(
FsException(
"no registered watch for path:" + path));
123 struct timeval timeoutStruct;
127 std::size_t buflen = 1024 * (
sizeof(
struct inotify_event) + 16);
130 inotify_event *event;
136 timeoutStruct.tv_sec = timeout / 1000;
137 timeoutStruct.tv_usec = (timeout % 1000) * 1000;
138 if ((ret = ::select(
_inotifyFd + 1, &readSet,
nullptr,
nullptr,
139 &timeoutStruct)) == -1)
149 throw(
FsException(
"unexpected file descriptor set"));
150 if ((len = read(
_inotifyFd, buf, buflen)) == -1)
159 for (
int i = 0; i < len;)
161 event =
reinterpret_cast<inotify_event *
>(
163 _watches.at(event->wd).mask |=
event->mask;
164 i +=
sizeof(inotify_event) + event->len;