Created
December 8, 2010 15:58
-
-
Save chobie/733469 to your computer and use it in GitHub Desktop.
pecl_inotifyを使ったディレクトリ監視(適当版)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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