uTools-Manuals/docs/php/eio_mknod.html
2019-04-08 23:22:26 +08:00

260 lines
9.5 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>Create a special or ordinary file</title>
</head>
<body class="docs"><div id="layout">
<div id="layout-content"><div id="function.eio-mknod" class="refentry">
<div class="refnamediv">
<h1 class="refname">eio_mknod</h1>
<p class="verinfo">(PECL eio &gt;= 0.0.1dev)</p><p class="refpurpose"><span class="refname">eio_mknod</span> &mdash; <span class="dc-title">Create a special or ordinary file</span></p>
</div>
<div class="refsect1 description" id="refsect1-function.eio-mknod-description">
<h3 class="title">说明</h3>
<div class="methodsynopsis dc-description">
<span class="methodname"><strong>eio_mknod</strong></span>
( <span class="methodparam"><span class="type">string</span> <code class="parameter">$path</code></span>
, <span class="methodparam"><span class="type">int</span> <code class="parameter">$mode</code></span>
, <span class="methodparam"><span class="type">int</span> <code class="parameter">$dev</code></span>
[, <span class="methodparam"><span class="type">int</span> <code class="parameter">$pri</code><span class="initializer"> = EIO_PRI_DEFAULT</span></span>
[, <span class="methodparam"><span class="type"><a href="language.types.callable.html" class="type callable">callable</a></span> <code class="parameter">$callback</code><span class="initializer"> = NULL</span></span>
[, <span class="methodparam"><span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span> <code class="parameter">$data</code><span class="initializer"> = NULL</span></span>
]]] ) : <span class="type">resource</span></div>
<p class="para rdfs-comment">
<span class="function"><strong>eio_mknod()</strong></span> creates ordinary or special(often) file.
</p>
<div class="warning"><strong class="warning">Warning</strong><p class="simpara">本函数还未编写文档,仅有参数列表。</p></div>
</div>
<div class="refsect1 parameters" id="refsect1-function.eio-mknod-parameters">
<h3 class="title">参数</h3>
<dl>
<dt>
<code class="parameter">path</code></dt>
<dd>
<p class="para">
Path for the new node(file).
</p>
</dd>
<dt>
<code class="parameter">mode</code></dt>
<dd>
<p class="para">
Specifies both the permissions to use and the type of node to be
created. It should be a combination (using bitwise OR) of one of the
file types listed below and the permissions for the new node(e.g. 0640).
Possible file types are: <strong><code>EIO_S_IFREG</code></strong>(regular file),
<strong><code>EIO_S_IFCHR</code></strong>(character file),
<strong><code>EIO_S_IFBLK</code></strong>(block special file),
<strong><code>EIO_S_IFIFO</code></strong>(FIFO - named pipe) and
<strong><code>EIO_S_IFSOCK</code></strong>(UNIX domain socket).
To specify permissions <em class="emphasis">EIO_S_I*</em> constants could be
used.
</p>
</dd>
<dt>
<code class="parameter">dev</code></dt>
<dd>
<p class="para">
If the file type is <strong><code>EIO_S_IFCHR</code></strong> or
<strong><code>EIO_S_IFBLK</code></strong> then dev specifies the major and minor
numbers of the newly created device special file. Otherwise
<code class="parameter">dev</code> ignored. See <em class="emphasis">mknod(2) man page for
details</em>.
</p>
</dd>
<dt>
<code class="parameter">pri</code></dt>
<dd>
<p class="para">请求的优先级:<strong><code>EIO_PRI_DEFAULT</code></strong><strong><code>EIO_PRI_MIN</code></strong><strong><code>EIO_PRI_MAX</code></strong><strong><code>NULL</code></strong>。如果是
<strong><code>NULL</code></strong><code class="parameter">pri</code> 将设为
<strong><code>EIO_PRI_DEFAULT</code></strong>
</p>
</dd>
<dt>
<code class="parameter">callback</code></dt>
<dd>
<p class="para">
<code class="parameter">callback</code>
函数在请求完成时被调用。其应匹配一下原型:<div class="example-contents"><div class="phpcode"><pre><span style="color: #000000">
void&nbsp;callback(mixed&nbsp;$data,&nbsp;int&nbsp;$result[,&nbsp;resource&nbsp;$req]);</span>
</pre></div></div>
<dl>
<dt>
<code class="parameter">data</code></dt>
<dd>
<p class="para">传递给请求的用户数据。</p></dd>
<dt>
<code class="parameter">result</code></dt>
<dd>
<p class="para">针对请求的结果的值。通常是相应的系统调用返回的值。</p></dd>
<dt>
<code class="parameter">req</code></dt>
<dd>
<p class="para">可选的请求资源,可被 <span class="function"><a href="eio_get_last_error.html" class="function">eio_get_last_error()</a></span>
之类的函数使用。</p></dd>
</dl>
</p>
</dd>
<dt>
<code class="parameter">data</code></dt>
<dd>
<p class="para">
Arbitrary variable passed to <code class="parameter">callback</code>.
</p>
</dd>
</dl>
</div>
<div class="refsect1 returnvalues" id="refsect1-function.eio-mknod-returnvalues">
<h3 class="title">返回值</h3>
<p class="para">
<span class="function"><strong>eio_mknod()</strong></span> returns request resource on success or <strong><code>FALSE</code></strong> on error.
</p>
</div>
<div class="refsect1 examples" id="refsect1-function.eio-mknod-examples">
<h3 class="title">范例</h3>
<div class="example" id="example-4279">
<p><strong>Example #1 <span class="function"><strong>eio_mknod()</strong></span> example</strong></p>
<div class="example-contents">
<div class="phpcode"><pre><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #FF8000">//&nbsp;FIFO&nbsp;name<br /></span><span style="color: #0000BB">$temp_filename&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">"/tmp/eio-temp-fifo"</span><span style="color: #007700">;<br /><br /></span><span style="color: #FF8000">/*&nbsp;Is&nbsp;called&nbsp;when&nbsp;eio_mknod()&nbsp;finishes&nbsp;*/<br /></span><span style="color: #007700">function&nbsp;</span><span style="color: #0000BB">my_mknod_callback</span><span style="color: #007700">(</span><span style="color: #0000BB">$data</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$result</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$s&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">stat</span><span style="color: #007700">(</span><span style="color: #0000BB">$data</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$s</span><span style="color: #007700">);<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(</span><span style="color: #0000BB">$result&nbsp;</span><span style="color: #007700">==&nbsp;</span><span style="color: #0000BB">0</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"eio_mknod_ok"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;@</span><span style="color: #0000BB">unlink</span><span style="color: #007700">(</span><span style="color: #0000BB">$data</span><span style="color: #007700">);<br />}<br /><br /></span><span style="color: #0000BB">eio_mknod</span><span style="color: #007700">(</span><span style="color: #0000BB">$temp_filename</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">EIO_S_IFIFO</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">0</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">EIO_PRI_DEFAULT</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"my_mknod_callback"</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$temp_filename</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">eio_event_loop</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</pre></div>
</div>
<div class="example-contents"><p>以上例程的输出类似于:</p></div>
<div class="example-contents screen">
<div class="cdata"><pre>
array(26) {
[0]=&gt;
int(17)
[1]=&gt;
int(2337608)
[2]=&gt;
int(4096)
[3]=&gt;
int(1)
[4]=&gt;
int(1000)
[5]=&gt;
int(100)
[6]=&gt;
int(0)
[7]=&gt;
int(0)
[8]=&gt;
int(1318241261)
[9]=&gt;
int(1318241261)
[10]=&gt;
int(1318241261)
[11]=&gt;
int(4096)
[12]=&gt;
int(0)
[&quot;dev&quot;]=&gt;
int(17)
[&quot;ino&quot;]=&gt;
int(2337608)
[&quot;mode&quot;]=&gt;
int(4096)
[&quot;nlink&quot;]=&gt;
int(1)
[&quot;uid&quot;]=&gt;
int(1000)
[&quot;gid&quot;]=&gt;
int(100)
[&quot;rdev&quot;]=&gt;
int(0)
[&quot;size&quot;]=&gt;
int(0)
[&quot;atime&quot;]=&gt;
int(1318241261)
[&quot;mtime&quot;]=&gt;
int(1318241261)
[&quot;ctime&quot;]=&gt;
int(1318241261)
[&quot;blksize&quot;]=&gt;
int(4096)
[&quot;blocks&quot;]=&gt;
int(0)
}
eio_mknod_ok
</pre></div>
</div>
</div>
</div>
<div class="refsect1 seealso" id="refsect1-function.eio-mknod-seealso">
<h3 class="title">参见</h3>
<ul class="simplelist">
<li class="member">eio_open</li>
</ul>
</div>
</div></div></div></body></html>