Skip to content

Instantly share code, notes, and snippets.

@chobie
Created December 8, 2010 15:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chobie/733469 to your computer and use it in GitHub Desktop.
Save chobie/733469 to your computer and use it in GitHub Desktop.
pecl_inotifyを使ったディレクトリ監視(適当版)
<?php
$fd = inotify_init();
$desc = inotify_add_watch($fd,"directory",IN_CLOSE_WRITE);
chdir(__DIR__);
array_shift($_SERVER["argv"]);
$command = __DIR__ . "/" . join(" ", $_SERVER["argv"]);
while($events = inotify_read($fd))
{
$files = array();
foreach($events as $event){
if(!in_array($event["name"],$files)){
$files[] = $event["name"];
}
}
foreach($files as $file){
passthru($command . $file);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment