| 1 |
<?php |
| 2 |
|
| 3 |
namespace Safe; |
| 4 |
|
| 5 |
use Safe\Exceptions\InotifyException; |
| 6 |
|
| 7 |
/** |
| 8 |
* Initialize an inotify instance for use with |
| 9 |
* inotify_add_watch |
| 10 |
* |
| 11 |
* @return resource A stream resource. |
| 12 |
* @throws InotifyException |
| 13 |
* |
| 14 |
*/ |
| 15 |
function inotify_init() |
| 16 |
{ |
| 17 |
error_clear_last(); |
| 18 |
$result = \inotify_init(); |
| 19 |
if ($result === false) { |
| 20 |
throw InotifyException::createFromPhpError(); |
| 21 |
} |
| 22 |
return $result; |
| 23 |
} |
| 24 |
|
| 25 |
|
| 26 |
/** |
| 27 |
* inotify_rm_watch removes the watch |
| 28 |
* watch_descriptor from the inotify instance |
| 29 |
* inotify_instance. |
| 30 |
* |
| 31 |
* @param resource $inotify_instance Resource returned by |
| 32 |
* inotify_init |
| 33 |
* @param int $watch_descriptor Watch to remove from the instance |
| 34 |
* @throws InotifyException |
| 35 |
* |
| 36 |
*/ |
| 37 |
function inotify_rm_watch($inotify_instance, int $watch_descriptor): void |
| 38 |
{ |
| 39 |
error_clear_last(); |
| 40 |
$result = \inotify_rm_watch($inotify_instance, $watch_descriptor); |
| 41 |
if ($result === false) { |
| 42 |
throw InotifyException::createFromPhpError(); |
| 43 |
} |
| 44 |
} |
| 45 |
|