| 213 | | define('FILE_NOTIFY_CHANGE_FILE_NAME', 0x00000001); |
| 214 | | define('FILE_NOTIFY_CHANGE_DIR_NAME', 0x00000002); |
| 215 | | define('FILE_NOTIFY_CHANGE_ATTRIBUTES', 0x00000004); |
| 216 | | define('FILE_NOTIFY_CHANGE_SIZE', 0x00000008); |
| 217 | | define('FILE_NOTIFY_CHANGE_LAST_WRITE', 0x00000010); |
| 218 | | define('FILE_NOTIFY_CHANGE_LAST_ACCESS', 0x00000020); |
| 219 | | define('FILE_NOTIFY_CHANGE_CREATION', 0x00000040); |
| 220 | | define('FILE_NOTIFY_CHANGE_EA', 0x00000080); |
| 221 | | define('FILE_NOTIFY_CHANGE_SECURITY', 0x00000100); |
| 222 | | define('FILE_NOTIFY_CHANGE_STREAM_NAME', 0x00000200); |
| 223 | | define('FILE_NOTIFY_CHANGE_STREAM_SIZE', 0x00000400); |
| 224 | | define('FILE_NOTIFY_CHANGE_STREAM_WRITE', 0x00000800); |
| 225 | | define('INFINITE', 0xffffffff); |
| 226 | | |
| 227 | | $kernel32 = wb_load_library('kernel32.dll'); |
| 228 | | while (true) { |
| 229 | | $h1 = wb_call_function(wb_get_function_address('FindFirstChangeNotification', $kernel32), |
| 230 | | array($directory, |
| 231 | | 1, |
| 232 | | FILE_NOTIFY_CHANGE_FILE_NAME | FILE_NOTIFY_CHANGE_DIR_NAME | FILE_NOTIFY_CHANGE_ATTRIBUTES | FILE_NOTIFY_CHANGE_LAST_WRITE | FILE_NOTIFY_CHANGE_EA | FILE_NOTIFY_CHANGE_SECURITY) |
| 233 | | ); |
| 234 | | |
| 235 | | print "Waiting for changes in the directory [ $directory ] ...\n"; |
| 236 | | $h2 = wb_call_function(wb_get_function_address('WaitForSingleObject', $kernel32), |
| 237 | | array($h1, INFINITE) |
| 238 | | ); |
| 239 | | passthru("$command " . implode(' ', $options), $result); |
| 240 | | |
| 241 | | $h3 = wb_call_function(wb_get_function_address('FindCloseChangeNotification', $kernel32), |
| 242 | | array($h1) |
| 243 | | ); |
| 244 | | |
| 245 | | if ($result !== 0) { |
| 246 | | return 1; |
| 247 | | } |
| | 208 | $monitor = new Stagehand_TestRunner_AlterationMonitor($directory, "$command " . implode(' ', $options)); |
| | 209 | |
| | 210 | try { |
| | 211 | $monitor->monitor(); |
| | 212 | } catch (Stagehand_TestRunner_Exception $e) { |
| | 213 | echo 'ERROR: ' . $e->getMessage() . "\n"; |
| | 214 | return 1; |