home *** CD-ROM | disk | FTP | other *** search
/ CD Actual Thematic 7: Programming / CDAT7.iso / Share / Editores / Perl5 / perl / lib / site / Win32 / ChangeNotify.pm < prev    next >
Encoding:
Perl POD Document  |  1997-08-10  |  2.6 KB  |  108 lines

  1. package Win32::ChangeNotify;
  2. use Carp;
  3.  
  4. $VERSION = '0.01';
  5.  
  6. =head1 NAME
  7.  
  8. ChangeNotify - monitor events related to files
  9.  
  10. =head1 SYNOPSIS
  11.  
  12.     use Win32::ChangeNotify;
  13.  
  14.     Win32::ChangeNotify::FindFirst($Obj,$PathName,$WatchSubTreeFlag,$filter);
  15.     $Obj->FindNext();
  16.     $Obj->Wait(INFINITE) or warn "Something failed: $!\n";
  17.     # There has been a change.
  18.     $Obj->Close();
  19.  
  20.  
  21. =head1 DESCRIPTION
  22.  
  23. This module allows the user to create a change notification event object
  24. in Perl.  This object allows the Perl program to monitor events relating
  25. to files and directory trees.
  26.  
  27. =head1 MEMBERS
  28.  
  29. The ChangeNotify module is written entirely in C++. So here is a 
  30. list of the members etc. (Note: no functions are exported)
  31.  
  32. =over 8
  33.  
  34. =item FindFirst($Obj,$PathName,$WathSubTree,$Filter)
  35.  
  36. This is the constructor for the object. An instantiated object is
  37. returned in $Obj.
  38.     Args:
  39.     $Obj        The container for the created object.
  40.     $WatchSubTree    A boolean value defining whether the subtree
  41.             should be included.
  42.     $Filter        See the exported values below to see the options
  43.             for this.
  44.  
  45. =item FindNext()
  46.  
  47. This method starts the monitoring.
  48.  
  49. =item Wait( $TimeOut )
  50.  
  51. This method starts the waiting on the change.
  52.  
  53. =item Close()
  54.  
  55. This method stops the monitoring.
  56.  
  57. =back
  58.  
  59. =cut
  60.  
  61. use Win32::IPC;
  62. require Exporter;
  63. require DynaLoader;
  64. require AutoLoader;
  65.  
  66. @ISA = qw(Exporter DynaLoader Win32::IPC);
  67. # Items to export into callers namespace by default. Note: do not export
  68. # names by default without a very good reason. Use EXPORT_OK instead.
  69. # Do not simply export all your public functions/methods/constants.
  70. @EXPORT = qw(
  71.     FILE_NOTIFY_CHANGE_ATTRIBUTES
  72.     FILE_NOTIFY_CHANGE_DIR_NAME
  73.     FILE_NOTIFY_CHANGE_FILE_NAME
  74.     FILE_NOTIFY_CHANGE_LAST_WRITE
  75.     FILE_NOTIFY_CHANGE_SECURITY
  76.     FILE_NOTIFY_CHANGE_SIZE
  77.     INFINITE
  78. );
  79.  
  80. sub AUTOLOAD {
  81.     # This AUTOLOAD is used to 'autoload' constants from the constant()
  82.     # XS function.  If a constant is not found then control is passed
  83.     # to the AUTOLOAD in AutoLoader.
  84.  
  85.     my($constname);
  86.     ($constname = $AUTOLOAD) =~ s/.*:://;
  87.     #reset $! to zero to reset any current errors.
  88.     $!=0;
  89.     my $val = constant($constname, @_ ? $_[0] : 0);
  90.     if ($! != 0) {
  91.     if ($! =~ /Invalid/) {
  92.         $AutoLoader::AUTOLOAD = $AUTOLOAD;
  93.         goto &AutoLoader::AUTOLOAD;
  94.     }
  95.     else {
  96.         ($pack,$file,$line) = caller;
  97.         die "Your vendor has not defined Win32::ChangeNotify macro $constname, used at $file line $line.";
  98.     }
  99.     }
  100.     eval "sub $AUTOLOAD { $val }";
  101.     goto &$AUTOLOAD;
  102. }
  103.  
  104. bootstrap Win32::ChangeNotify;
  105.  
  106. 1;
  107. __END__
  108.