📄 lseek.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"><html><head><!-- Copyright 1997 The Open Group, All Rights Reserved --><title>lseek</title></head><body bgcolor=white><center><font size=2>The Single UNIX ® Specification, Version 2<br>Copyright © 1997 The Open Group</font></center><hr size=2 noshade><h4><a name = "tag_000_007_469"> </a>NAME</h4><blockquote>lseek - move the read/write file offset</blockquote><h4><a name = "tag_000_007_470"> </a>SYNOPSIS</h4><blockquote><pre><code>#include <<a href="systypes.h.html">sys/types.h</a>>#include <<a href="unistd.h.html">unistd.h</a>>off_t lseek(int <i>fildes</i>, off_t <i>offset</i>, int <i>whence</i>);</code></pre></blockquote><h4><a name = "tag_000_007_471"> </a>DESCRIPTION</h4><blockquote>The<i>lseek()</i>function will set the file offset for the open file descriptionassociated with the file descriptor<i>fildes,</i>as follows:<ul><p><li>If<i>whence</i>is SEEK_SET the file offset is set to<i>offset</i>bytes.<p><li>If<i>whence</i>is SEEK_CUR the file offset is set to its current location plus<i>offset</i>.<p><li>If<i>whence</i>is SEEK_END the file offset is set to the size of the file plus<i>offset</i>.<p></ul><p>The symbolic constants SEEK_SET, SEEK_CUR and SEEK_ENDare defined in the header<i><a href="unistd.h.html"><unistd.h></a></i>.<p>The behaviour of<i>lseek()</i>on devices which are incapable of seeking is implementation-dependent. Thevalue of the file offset associated with such a device is undefined.<p>The<i>lseek()</i>function will allow the file offset to be set beyond the end of the existingdata in the file. If data is later written at this point, subsequent reads ofdata in the gap will return bytes with the value 0 until data is actuallywritten into the gap.<p>The<i>lseek()</i>function will not, by itself, extend the size of a file.<p>If<i>fildes</i>refers to a shared memory object, the result of the<i>lseek()</i>function is unspecified.</blockquote><h4><a name = "tag_000_007_472"> </a>RETURN VALUE</h4><blockquote>Upon successful completion, the resulting offset,as measured in bytes from the beginning of the file, is returned.Otherwise, (<b>off_t</b>)-1 is returned,<i>errno</i>is set to indicate the error and the file offset will remain unchanged.</blockquote><h4><a name = "tag_000_007_473"> </a>ERRORS</h4><blockquote>The<i>lseek()</i>function will fail if:<dl compact><dt>[EBADF]<dd>The<i>fildes</i>argument is not an open file descriptor.<dt>[EINVAL]<dd>The<i>whence</i>argument is not a proper value, or the resulting file offsetwould be invalid.<dt>[EOVERFLOW]<dd>The resulting file offset would be a value which cannot be representedcorrectly in an object of type <b>off_t</b>.<dt>[ESPIPE]<dd>The<i>fildes</i>argument is associated with a pipe or FIFO.</dl></blockquote><h4><a name = "tag_000_007_474"> </a>EXAMPLES</h4><blockquote>None.</blockquote><h4><a name = "tag_000_007_475"> </a>APPLICATION USAGE</h4><blockquote>None.</blockquote><h4><a name = "tag_000_007_476"> </a>FUTURE DIRECTIONS</h4><blockquote>None.</blockquote><h4><a name = "tag_000_007_477"> </a>SEE ALSO</h4><blockquote><i><a href="open.html">open()</a></i>,<i><a href="systypes.h.html"><sys/types.h></a></i>,<i><a href="unistd.h.html"><unistd.h></a></i>.</blockquote><h4>DERIVATION</h4><blockquote>Derived from Issue 1 of the SVID.</blockquote><hr size=2 noshade><center><font size=2>UNIX ® is a registered Trademark of The Open Group.<br>Copyright © 1997 The Open Group<br> [ <a href="../index.html">Main Index</a> | <a href="../xshix.html">XSH</a> | <a href="../xcuix.html">XCU</a> | <a href="../xbdix.html">XBD</a> | <a href="../cursesix.html">XCURSES</a> | <a href="../xnsix.html">XNS</a> ]</font></center><hr size=2 noshade></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -