Mon May 21 10:31:14 2012: Request 77261 was acted upon. Transaction: Correspondence added by david.zh...@bowker.com Queue: Win32-IPC Subject: RE: [rt.cpan.org #77261] Win32::ChangeNotify always watches subtree Broken in: 1.09 Severity: Unimportant Owner: Nobody Requestors: david.zh...@bowker.com Status: rejected Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=77261 >
Hello Chris, Can Win32::ChangeNotify return more messages such as which files or folders are modified? Are there any other modules for this purpose? Many thanks David Zhang -----Original Message----- From: Christopher J. Madsen via RT [mailto:bug-win32-...@rt.cpan.org] Sent: Thursday, May 17, 2012 4:29 PM To: Zhang, David Subject: [rt.cpan.org #77261] Win32::ChangeNotify always watches subtree <URL: https://rt.cpan.org/Ticket/Display.html?id=77261 > This turns out to be a problem with the underlying FindFirstChangeNotification API. There's nothing I can do about it. Here's the program I used to test it: use 5.010; use strict; use warnings; use Win32::ChangeNotify; my $notify = Win32::ChangeNotify->new(".", 0, # no subtree 'FILE_NAME DIR_NAME LAST_WRITE'); say 'waiting...'; while ($notify->wait) { say "change!"; $notify->reset; } I ran that script, and then in another console created & removed files in the watched directory and subdirectories of it. I sometimes got a notification when changing files in a subdirectory (although not all the time). I verified that it's a Windows bug by running the equivalent C program, which gave similar results: #define WIN32_LEAN_AND_MEAN #include <windows.h> #include <stdio.h> int main(int argc, char* argv[]) { HANDLE cn = FindFirstChangeNotification(".", FALSE, FILE_NOTIFY_CHANGE_FILE_NAME | FILE_NOTIFY_CHANGE_DIR_NAME | FILE_NOTIFY_CHANGE_LAST_WRITE ); puts("waiting"); while (WaitForSingleObject(cn, INFINITE) == WAIT_OBJECT_0) { puts("change!"); FindNextChangeNotification(cn); } return 0; } /* end main */