Skip to content

Commit 2ac95ee

Browse files
add remove method (#5)
1 parent e6bafc7 commit 2ac95ee

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ class RecommendedWatcher
4747

4848
public function add(string $path, bool $recursive = true): void;
4949

50+
public function remove(string $path): void;
51+
5052
/**
5153
* @param callable(Event): void $handle
5254
*/

src/lib.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,16 @@ pub fn get_module() -> Module {
5353
.argument(Argument::by_val("path"))
5454
.argument(Argument::by_val_optional("recursive"));
5555

56+
watcher.add_method("remove", Visibility::Public, |this, arguments| {
57+
let path = arguments[0].expect_z_str()?;
58+
59+
let map = this.get_mut_property("map").expect_mut_z_arr()?;
60+
map.remove(path);
61+
62+
Ok::<_, phper::Error>(())
63+
})
64+
.argument(Argument::by_val("path"));
65+
5666
watcher.add_method("watch", Visibility::Public, |this, arguments| {
5767
let handler = arguments.get_mut(0).unwrap();
5868
let (tx, rx) = std::sync::mpsc::channel();

tests/php/recommended_watcher.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
$watcher = new FsNotify\RecommendedWatcher();
88
$watcher->add(__DIR__);
9+
$watcher->remove(__DIR__);
10+
$watcher->remove('unknown');
911
$watcher->add(__DIR__, recursive: false);
1012
$watcher->watch(function (FsNotify\Event $event) {
1113
var_dump($event->getKind());

0 commit comments

Comments
 (0)