event/InotifyEvent: add method TryAddWatch()
This commit is contained in:
parent
db5f270f42
commit
7c0b561a16
|
@ -34,11 +34,17 @@ InotifyEvent::~InotifyEvent() noexcept
|
|||
Close();
|
||||
}
|
||||
|
||||
int
|
||||
InotifyEvent::TryAddWatch(const char *pathname, uint32_t mask) noexcept
|
||||
{
|
||||
return inotify_add_watch(event.GetFileDescriptor().Get(),
|
||||
pathname, mask);
|
||||
}
|
||||
|
||||
int
|
||||
InotifyEvent::AddWatch(const char *pathname, uint32_t mask)
|
||||
{
|
||||
int wd = inotify_add_watch(event.GetFileDescriptor().Get(),
|
||||
pathname, mask);
|
||||
int wd = TryAddWatch(pathname, mask);
|
||||
if (wd < 0)
|
||||
throw FmtErrno("inotify_add_watch('{}') failed", pathname);
|
||||
|
||||
|
|
|
@ -84,6 +84,12 @@ public:
|
|||
*/
|
||||
int AddWatch(const char *pathname, uint32_t mask);
|
||||
|
||||
/**
|
||||
* Like AddWatch(), but returns -1 instead of throwing on
|
||||
* error.
|
||||
*/
|
||||
int TryAddWatch(const char *pathname, uint32_t mask) noexcept;
|
||||
|
||||
/**
|
||||
* Wrapper for AddWatch(pathname, IN_MODIFY).
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue