|new %ARGS||Creates a new instance. The %ARGS hash has two possible keys, Method, which denotes the method used for checking as default, and Files, which takes an array reference to the filenames to watch.|
|add filename, method||Adds a new file to watch. method is the method (or rather, the subclass of File::Modified::Signature) to use to determine whether a file has changed or not. The result is either the File::Modified::Signature subclass or undef if an error occurred.|
|addfile LIST||Adds a list of files to watch. The method used for watching is the default method as set in the constructor. The result is a list of File::Modified::Signature subclasses.|
|update||Updates all signatures to the current state. All pending changes are discarded.|
|changed||Returns a list of the filenames whose files did change since the construction or the last call to update (whichever last occurred).|
The module also creates a new namespace File::Signature, which sometime will evolve into its own module in its own file. A file signature is most likely of little interest to you; the only time you might want to access the signature directly is to store the signature in a file for persistence and easy comparision whether an index database is current with the actual data.
The interface is settled, there are two methods, as_scalar and from_scalar, that you use to freeze and thaw the signatures. The implementation of these methods is very frugal, there are no provisions made against filenames that contain weird characters like \n or | (the pipe bar), both will be likely to mess up your one-line-per-file database. An interesting method could be to URL-encode all filenames, but I will visit this topic in the next release. Also, complex (that is, non-scalar) signatures are handled rather ungraceful at the moment.
Currently, Im planning to use Text::Quote as a quoting mechanism to protect against multiline filenames.
Adding a new signature method is as simple as creating a new subclass of File::Signature. See File::Signature::Checksum for a simple example. There is one point of laziness in the implementation of File::Signature, the check method can only compare strings instead of arbitrary structures (yes, there ARE things that are easier in Python than in Perl). File::Signature::Digest is a wrapper for Gisle Aas Digest module and allows you to use any module below the Digest namespace as a signature, for example File::Signature::MD5 and File::Signature::SHA1.
* Make the simple persistence solution for the signatures better using Text::Quote.
* Allow complex structures for the signatures.
* Document File::Modified::Signature or put it down into another namespace.
* Extract the File::Modified::Signature subclasses out into their own file.
* Create an easy option to watch a whole directory tree.
None by default.
File::Monitor will watch a file or directory, invoking a callback when it changes.
File::Monitor::Simple watches a directory for changes to any files whose name matches a regular expression.
File::IfModified provides a function that can be used to check whether a file has been modified since the last time you checked.
File::Stat::Trigger will invoke one of your callbacks if the stat() details of a file change.
Win32::FileSystem::Watcher provides a Windows-specific solution for watching for changes to a filesystem. The documentation is extremely limited, so I cant tell if you can limit it a specific directory.
App::watcher comes with a script that will run a command if any of the files in a directory are changed.
POE::Component::DirWatch watches a directory for new files or directories, invoking a user-supplied callback function when one is seen.
WWW::Monitor is similar to File::Monitor, but checks URLs rather than files.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Copyright (C) 2002 Max Maischein
Max Maischein, <email@example.com>
Please contact me if you find bugs or otherwise improve the module. More tests are also very welcome !
|perl v5.20.3||FILE::MODIFIED (3)||2015-10-26|