Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Watching for files to change

by The_Dj (Beadle)
on Nov 09, 2013 at 15:52 UTC ( [id://1061834]=perlquestion: print w/replies, xml ) Need Help??

The_Dj has asked for the wisdom of the Perl Monks concerning the following question:

Greetings Monks.

I need to watch for files appearing, dissapearing or changing.
My environment is Windows (several server versions) and Strawberryperl 5.18.
I also need to be as resource-light as possible as many target servers run at close to or over loaded.

Naturally Win32::FileSystem::Watcher seems to be the best solution since it does evrything I need

But I have a strange problem:
While the watcher is watching a directory any attempt to rename a file is met with a popup 'cannot rename <file> it is being used...'.
However I can create, modify or delete with no problems.

I'm testing with a very simple program:
use Win32::FileSystem::Watcher; my $watcher = Win32::FileSystem::Watcher->new("c:\\test"); $watcher->start(); while (1) { my @entries = $watcher->get_results(); foreach my $entry (@entries) { print $entry->action_name . " " . $entry->file_name . "\n"; } sleep 2; }
Any help?

Replies are listed 'Best First'.
Re: Watching for files to change
by kcott (Archbishop) on Nov 09, 2013 at 17:35 UTC

    G'day The_Dj,

    That's a known bug (#62454) that was raised over three years ago and is still flagged as "new".

    The bug report contains a potential solution that may be suitable for your needs.

    Another workaround might be to copy and delete instead of renaming.

    -- Ken

      Thanks, Ken

      That's brilliant! ☺
      The 'workaround' in the bug report looks to be better described as a 'fix'

      Any reason that can't be applied to the official CPAN module?

      Thanks again!
        "Any reason that can't be applied to the official CPAN module?"

        You'll need to contact the module author regarding that.

        -- Ken

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1061834]
Approved by hdb
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (6)
As of 2024-04-23 14:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found