USING: accessors combinators io io.monitors kernel sequences ; IN: test.watchdir : launch-watchdir ( dir quot -- ) t swap [ spawn-monitor ] with-monitors ; : handle-change ( changes -- ) [ path>> ] [ changed>> ] bi [ { { +add-file+ [ dup write " was created." print ] } { +remove-file+ [ dup write " was removed." print ] } { +modify-file+ [ dup write " was modified." print ] } [ drop dup write " was renamed." print ] } case flush ] each drop ; : test-watchdir ( dir -- ) [ dup next-change handle-change ] launch-watchdir ;