seekable.html
来自「perl教程」· HTML 代码 · 共 142 行
HTML
142 行
<?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>IO::Seekable - supply seek based methods for I/O objects</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>IO::Seekable - supply seek based methods for I/O objects</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>
<li><a href="#see_also">SEE ALSO</a></li>
<li><a href="#history">HISTORY</a></li>
</ul>
<!-- INDEX END -->
<hr />
<p>
</p>
<h1><a name="name">NAME</a></h1>
<p>IO::Seekable - supply seek based methods for I/O objects</p>
<p>
</p>
<hr />
<h1><a name="synopsis">SYNOPSIS</a></h1>
<pre>
<span class="keyword">use</span> <span class="variable">IO::Seekable</span><span class="operator">;</span>
<span class="keyword">package</span> <span class="variable">IO::Something</span><span class="operator">;</span>
<span class="variable">@ISA</span> <span class="operator">=</span> <span class="string">qw(IO::Seekable)</span><span class="operator">;</span>
</pre>
<p>
</p>
<hr />
<h1><a name="description">DESCRIPTION</a></h1>
<p><code>IO::Seekable</code> does not have a constructor of its own as it is intended to
be inherited by other <code>IO::Handle</code> based objects. It provides methods
which allow seeking of the file descriptors.</p>
<dl>
<dt><strong><a name="item_getpos">$io->getpos</a></strong>
<dd>
<p>Returns an opaque value that represents the current position of the
IO::File, or <a href="../../lib/Pod/perlfunc.html#item_undef"><code>undef</code></a> if this is not possible (eg an unseekable stream such
as a terminal, pipe or socket). If the <code>fgetpos()</code> function is available in
your C library it is used to implements getpos, else perl emulates getpos
using C's <code>ftell()</code> function.</p>
</dd>
</li>
<dt><strong><a name="item_setpos">$io->setpos</a></strong>
<dd>
<p>Uses the value of a previous getpos call to return to a previously visited
position. Returns "0 but true" on success, <a href="../../lib/Pod/perlfunc.html#item_undef"><code>undef</code></a> on failure.</p>
</dd>
</li>
</dl>
<p>See <a href="../../lib/Pod/perlfunc.html">the perlfunc manpage</a> for complete descriptions of each of the following
supported <code>IO::Seekable</code> methods, which are just front ends for the
corresponding built-in functions:</p>
<dl>
<dt><strong><a name="item_seek">$io->seek ( POS, WHENCE )</a></strong>
<dd>
<p>Seek the IO::File to position POS, relative to WHENCE:</p>
</dd>
<dl>
<dt><strong><a name="item_0">WHENCE=0 (SEEK_SET)</a></strong>
<dd>
<p>POS is absolute position. (Seek relative to the start of the file)</p>
</dd>
</li>
<dt><strong><a name="item_1">WHENCE=1 (SEEK_CUR)</a></strong>
<dd>
<p>POS is an offset from the current position. (Seek relative to current)</p>
</dd>
</li>
<dt><strong><a name="item_2">WHENCE=2 (SEEK_END)</a></strong>
<dd>
<p>POS is an offset from the end of the file. (Seek relative to end)</p>
</dd>
</li>
</dl>
<p>The SEEK_* constants can be imported from the <code>Fcntl</code> module if you
don't wish to use the numbers <code>0</code> <a href="#item_1"><code>1</code></a> or <a href="#item_2"><code>2</code></a> in your code.</p>
<p>Returns <a href="#item_1"><code>1</code></a> upon success, <code>0</code> otherwise.</p>
<dt><strong><a name="item_sysseek">$io->sysseek( POS, WHENCE )</a></strong>
<dd>
<p>Similar to $io->seek, but sets the IO::File's position using the system
call <code>lseek(2)</code> directly, so will confuse most perl IO operators except
sysread and syswrite (see <a href="../../lib/Pod/perlfunc.html">the perlfunc manpage</a> for full details)</p>
</dd>
<dd>
<p>Returns the new position, or <a href="../../lib/Pod/perlfunc.html#item_undef"><code>undef</code></a> on failure. A position
of zero is returned as the string <code>"0 but true"</code></p>
</dd>
</li>
<dt><strong><a name="item_tell">$io->tell</a></strong>
<dd>
<p>Returns the IO::File's current position, or -1 on error.</p>
</dd>
</li>
</dl>
<p>
</p>
<hr />
<h1><a name="see_also">SEE ALSO</a></h1>
<p><a href="../../lib/Pod/perlfunc.html">the perlfunc manpage</a>,
<a href="../../lib/Pod/perlop.html#i_o_operators">I/O Operators in the perlop manpage</a>,
<a href="../../lib/IO/Handle.html">the IO::Handle manpage</a>
<a href="../../lib/IO/File.html">the IO::File manpage</a></p>
<p>
</p>
<hr />
<h1><a name="history">HISTORY</a></h1>
<p>Derived from FileHandle.pm by Graham Barr <<a href="mailto:gbarr@pobox.com">gbarr@pobox.com</a>></p>
</body>
</html>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?