changenotify.html
来自「perl教程」· HTML 代码 · 共 168 行
HTML
168 行
<?xml version="1.0" ?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<!-- saved from url=(0017)http://localhost/ -->
<script language="JavaScript" src="../../displayToc.js"></script>
<script language="JavaScript" src="../../tocParas.js"></script>
<script language="JavaScript" src="../../tocTab.js"></script>
<link rel="stylesheet" type="text/css" href="../../scineplex.css">
<title>Win32::ChangeNotify - Monitor events related to files and directories</title>
<link rel="stylesheet" href="../../Active.css" type="text/css" />
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link rev="made" href="mailto:" />
</head>
<body>
<script>writelinks('__top__',2);</script>
<h1><a>Win32::ChangeNotify - Monitor events related to files and directories</a></h1>
<p><a name="__index__"></a></p>
<!-- INDEX BEGIN -->
<ul>
<li><a href="#name">NAME</a></li>
<li><a href="#synopsis">SYNOPSIS</a></li>
<li><a href="#description">DESCRIPTION</a></li>
<ul>
<li><a href="#methods">Methods</a></li>
<li><a href="#deprecated_functions_and_methods">Deprecated Functions and Methods</a></li>
</ul>
<li><a href="#author">AUTHOR</a></li>
</ul>
<!-- INDEX END -->
<hr />
<p>
</p>
<h1><a name="name">NAME</a></h1>
<p>Win32::ChangeNotify - Monitor events related to files and directories</p>
<p>
</p>
<hr />
<h1><a name="synopsis">SYNOPSIS</a></h1>
<pre>
<span class="keyword">require</span> <span class="variable">Win32::ChangeNotify</span><span class="operator">;</span>
</pre>
<pre>
<span class="variable">$notify</span> <span class="operator">=</span> <span class="variable">Win32::ChangeNotify</span><span class="operator">-></span><span class="variable">new</span><span class="operator">(</span><span class="variable">$Path</span><span class="operator">,</span><span class="variable">$WatchSubTree</span><span class="operator">,</span><span class="variable">$Events</span><span class="operator">);</span>
<span class="variable">$notify</span><span class="operator">-></span><span class="keyword">wait</span> <span class="keyword">or</span> <span class="keyword">warn</span> <span class="string">"Something failed: $!\n"</span><span class="operator">;</span>
<span class="comment"># There has been a change.</span>
</pre>
<p>
</p>
<hr />
<h1><a name="description">DESCRIPTION</a></h1>
<p>This module allows the user to use a Win32 change notification event
object from Perl. This allows the Perl program to monitor events
relating to files and directory trees.</p>
<p>Unfortunately, the Win32 API which implements this feature does not
provide any indication of <em>what</em> triggered the notification (as far
as I know). If you're monitoring a directory for file changes, and
you need to know <em>which</em> file changed, you'll have to find some other
way of determining that. Depending on exactly what you're trying to
do, you may be able to check file timestamps to find recently changed
files. Or, you may need to cache the directory contents somewhere and
compare the current contents to your cached copy when you receive a
change notification.</p>
<p>The <a href="#item_wait"><code>wait</code></a> method and <code>wait_all</code> & <code>wait_any</code> functions are
inherited from the <a href="#win32__ipc">Win32::IPC</a> module.</p>
<p>
</p>
<h2><a name="methods">Methods</a></h2>
<dl>
<dt><strong><a name="item_new">$notify = Win32::ChangeNotify->new($path, $subtree, $filter)</a></strong>
<dd>
<p>Constructor for a new ChangeNotification object. <code>$path</code> is the
directory to monitor. If <code>$subtree</code> is true, then all directories
under <code>$path</code> will be monitored. <code>$filter</code> indicates what events
should trigger a notification. It should be a string containing any
of the following flags (separated by whitespace and/or <code>|</code>).</p>
</dd>
<dd>
<pre>
ATTRIBUTES Any attribute change
DIR_NAME Any directory name change
FILE_NAME Any file name change (creating/deleting/renaming)
LAST_WRITE Any change to a file's last write time
SECURITY Any security descriptor change
SIZE Any change in a file's size</pre>
</dd>
<dd>
<p>(<code>$filter</code> can also be an integer composed from the
<code>FILE_NOTIFY_CHANGE_*</code> constants.)</p>
</dd>
</li>
<dt><strong><a name="item_close">$notify->close</a></strong>
<dd>
<p>Shut down monitoring. You could just <code>undef $notify</code> instead (but
<a href="#item_close"><code>close</code></a> works even if there are other copies of the object). This
happens automatically when your program exits.</p>
</dd>
</li>
<dt><strong><a name="item_reset">$notify->reset</a></strong>
<dd>
<p>Resets the ChangeNotification object after a change has been detected.
The object will become signalled again after the next change. (It is
OK to call this immediately after <a href="#item_new"><code>new</code></a>, but it is not required.)</p>
</dd>
</li>
<dt><strong><a name="item_wait">$notify->wait</a></strong>
<dd>
<p>See <a href="#win32__ipc">Win32::IPC</a>. Remember to call <a href="#item_reset"><code>reset</code></a> afterwards if you want
to continue monitoring.</p>
</dd>
</li>
</dl>
<p>
</p>
<h2><a name="deprecated_functions_and_methods">Deprecated Functions and Methods</a></h2>
<p><strong>Win32::ChangeNotify</strong> still supports the ActiveWare syntax, but its
use is deprecated.</p>
<dl>
<dt><strong><a name="item_findfirst"><code>FindFirst($Obj,$PathName,$WatchSubTree,$Filter)</code></a></strong>
<dd>
<p>Use</p>
</dd>
<dd>
<pre>
$Obj = Win32::ChangeNotify->new($PathName,$WatchSubTree,$Filter)</pre>
</dd>
<dd>
<p>instead.</p>
</dd>
</li>
<dt><strong><a name="item_findnext">$obj-><code>FindNext()</code></a></strong>
<dd>
<p>Use <a href="#item_reset"><code>$obj->reset</code></a> instead.</p>
</dd>
</li>
<dt><strong><a name="item_close">$obj-><code>Close()</code></a></strong>
<dd>
<p>Use <a href="#item_close"><code>$obj->close</code></a> instead.</p>
</dd>
</li>
</dl>
<p>
</p>
<hr />
<h1><a name="author">AUTHOR</a></h1>
<p>Christopher J. Madsen <<em><a href="mailto:cjm@pobox.com">cjm@pobox.com</a></em>></p>
<p>Loosely based on the original module by ActiveWare Internet Corp.,
<em><a href="http://www.ActiveWare.com">http://www.ActiveWare.com</a></em></p>
</body>
</html>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?