466
|
1 <refentry id="lseek">
|
|
2 <refnamediv>
|
468
|
3 <refname>Lseek</refname>
|
|
4 <refpurpose>position in file</refpurpose>
|
466
|
5 </refnamediv>
|
|
6
|
|
7 <refsynopsisdiv>
|
|
8 <funcsynopsis>
|
|
9 <funcprototype>
|
|
10 <funcdef><function>lseek</function></funcdef>
|
570
|
11 <paramdef>int <parameter>pn</parameter></paramdef>
|
|
12 <paramdef>long <parameter>position</parameter></paramdef>
|
|
13 <paramdef>int <parameter>type</parameter></paramdef>
|
466
|
14 </funcprototype>
|
|
15 </funcsynopsis>
|
|
16
|
|
17 </refsynopsisdiv>
|
|
18
|
542
|
19 <refsect1><title>Assembler Equivalent</title>
|
|
20 <para>
|
|
21 os9 I$SEEK
|
|
22 </para>
|
|
23 </refsect1>
|
|
24
|
466
|
25 <refsect1><title>Description</title>
|
|
26 <para>
|
602
|
27 The read or write pointer for the open file with the path
|
|
28 number, "pn", is positioned by lseek to the specified place in
|
|
29 the file. The "type" indicates from where "position" is to be
|
|
30 measured: if 0, from the beginning of the file, if 1, from the
|
|
31 current location, or if 2, from the end of the file.
|
|
32 </para>
|
|
33 <para>
|
|
34 Seeking to a location beyond the end of a file open for
|
|
35 writing and then writing to it, creates a "hole" in the file
|
|
36 which appears to be filled with zeros from the previous end to
|
|
37 the position sought.
|
|
38 </para>
|
|
39 <para>
|
|
40 The returned value is the resulting position in the file unless
|
|
41 there is an error, so to find out the current position use
|
|
42 <informalexample>
|
|
43 <para>
|
|
44 lseek(pn,0l,1);
|
|
45 </para>
|
|
46 </informalexample>
|
|
47 </para>
|
|
48 </refsect1>
|
|
49
|
|
50 <refsect1><title>Caveats</title>
|
|
51 <para>
|
|
52 The argument "position" <emphasis>must</emphasis> be a long integer. Constants
|
|
53 should be explicitly made long by appending an "l", as above,
|
|
54 and other types should be converted using a cast:
|
|
55 <informalexample>
|
|
56 <para>
|
|
57 e.g. lseek(pn,(long)pos,1);
|
|
58 </para>
|
|
59 </informalexample>
|
|
60 Notice also, that the return value from lseek is itself a long integer.
|
466
|
61 </para>
|
|
62 </refsect1>
|
542
|
63
|
552
|
64 <refsect1><title>Diagnostics</title>
|
|
65 <para>
|
|
66 -1 is returned if "pn" is a bad path number, or attempting to
|
|
67 seek to a position before the beginning of a file.
|
|
68 </para>
|
|
69 </refsect1>
|
|
70
|
542
|
71 <refsect1><title>See Also</title>
|
|
72 <para>
|
|
73 <link linkend="creat">creat()</link>,
|
|
74 <link linkend="open">open()</link>,
|
|
75 Standard Library function
|
|
76 <link linkend="fseek">"fseek"</link>
|
|
77 </para>
|
|
78 </refsect1>
|
|
79
|
466
|
80 </refentry>
|