Thu May 17 16:33:41 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: (no value)
    Severity: Unimportant
       Owner: Nobody
  Requestors: david.zh...@bowker.com
      Status: rejected
 Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=77261 >


Thank you so much for your quick response.
I like your modules. Actually the subtree issue doesn't bother me too much.
All I need to do is to add more codes to find out where the changes are from.

Thanks again.

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 */


Reply via email to