2026-03-30 14:54:57 +07:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace Safe;
|
|
|
|
|
|
|
|
|
|
use Safe\Exceptions\InotifyException;
|
|
|
|
|
|
|
|
|
|
/**
|
2026-04-18 20:32:18 +07:00
|
|
|
* @param resource $inotify_instance
|
|
|
|
|
* @param string $pathname
|
|
|
|
|
* @param int $mask
|
|
|
|
|
* @return int
|
2026-03-30 14:54:57 +07:00
|
|
|
* @throws InotifyException
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
function inotify_add_watch($inotify_instance, string $pathname, int $mask): int
|
|
|
|
|
{
|
|
|
|
|
error_clear_last();
|
|
|
|
|
$safeResult = \inotify_add_watch($inotify_instance, $pathname, $mask);
|
|
|
|
|
if ($safeResult === false) {
|
|
|
|
|
throw InotifyException::createFromPhpError();
|
|
|
|
|
}
|
|
|
|
|
return $safeResult;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2026-04-18 20:32:18 +07:00
|
|
|
* @return resource
|
2026-03-30 14:54:57 +07:00
|
|
|
* @throws InotifyException
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
function inotify_init()
|
|
|
|
|
{
|
|
|
|
|
error_clear_last();
|
|
|
|
|
$safeResult = \inotify_init();
|
|
|
|
|
if ($safeResult === false) {
|
|
|
|
|
throw InotifyException::createFromPhpError();
|
|
|
|
|
}
|
|
|
|
|
return $safeResult;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2026-04-18 20:32:18 +07:00
|
|
|
* @param resource $inotify_instance
|
|
|
|
|
* @param int $watch_descriptor
|
2026-03-30 14:54:57 +07:00
|
|
|
* @throws InotifyException
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
function inotify_rm_watch($inotify_instance, int $watch_descriptor): void
|
|
|
|
|
{
|
|
|
|
|
error_clear_last();
|
|
|
|
|
$safeResult = \inotify_rm_watch($inotify_instance, $watch_descriptor);
|
|
|
|
|
if ($safeResult === false) {
|
|
|
|
|
throw InotifyException::createFromPhpError();
|
|
|
|
|
}
|
|
|
|
|
}
|