OSDN Git Service

28004bc7888736f295c6d8b26bae3578fbdeb57f
[linuxjm/LDP_man-pages.git] / draft / man3 / fseek.3
1 .\" Copyright (c) 1990, 1991 The Regents of the University of California.
2 .\" All rights reserved.
3 .\"
4 .\" This code is derived from software contributed to Berkeley by
5 .\" Chris Torek and the American National Standards Committee X3,
6 .\" on Information Processing Systems.
7 .\"
8 .\" Redistribution and use in source and binary forms, with or without
9 .\" modification, are permitted provided that the following conditions
10 .\" are met:
11 .\" 1. Redistributions of source code must retain the above copyright
12 .\"    notice, this list of conditions and the following disclaimer.
13 .\" 2. Redistributions in binary form must reproduce the above copyright
14 .\"    notice, this list of conditions and the following disclaimer in the
15 .\"    documentation and/or other materials provided with the distribution.
16 .\" 3. All advertising materials mentioning features or use of this software
17 .\"    must display the following acknowledgement:
18 .\"     This product includes software developed by the University of
19 .\"     California, Berkeley and its contributors.
20 .\" 4. Neither the name of the University nor the names of its contributors
21 .\"    may be used to endorse or promote products derived from this software
22 .\"    without specific prior written permission.
23 .\"
24 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 .\" SUCH DAMAGE.
35 .\"
36 .\"     @(#)fseek.3     6.11 (Berkeley) 6/29/91
37 .\"
38 .\" Converted for Linux, Mon Nov 29 15:22:01 1993, faith@cs.unc.edu
39 .\"
40 .\"
41 .\" Japanese Version Copyright (c) 1998 NAKANO Takeo all rights reserved.
42 .\" Translated Mon Apr 27 1998 by NAKANO Takeo <nakano@apm.seikei.ac.jp>
43 .\"
44 .\" WORD:       file position indicator ファイル位置表示子
45 .\" WORD:       error indicator         エラー表示子
46 .\"
47 .TH FSEEK 3  1993-11-29 "GNU" "Linux Programmer's Manual"
48 .\"O .SH NAME
49 .\"O fgetpos, fseek, fsetpos, ftell, rewind \- reposition a stream
50 .SH 名前
51 fgetpos, fseek, fsetpos, ftell, rewind \- ストリームの位置を変更する
52 .\"O .SH SYNOPSIS
53 .SH 書式
54 .B #include <stdio.h>
55 .sp
56 .BI "int fseek(FILE *" stream ", long " offset ", int " whence );
57
58 .BI "long ftell(FILE *" stream );
59
60 .BI "void rewind(FILE *" stream );
61
62 .BI "int fgetpos(FILE *" stream ", fpos_t *" pos );
63 .br
64 .BI "int fsetpos(FILE *" stream ", fpos_t *" pos );
65 .\"O .SH DESCRIPTION
66 .SH 説明
67 .\"O The
68 .\"O .BR fseek ()
69 .\"O function sets the file position indicator for the stream pointed to by
70 .\"O .IR stream .
71 .\"O The new position, measured in bytes, is obtained by adding
72 .\"O .I offset
73 .\"O bytes to the position specified by
74 .\"O .IR whence .
75 .BR fseek ()
76 関数は
77 .I stream
78 によって指定されたストリームにおいて、ファイル位置表示子
79 (file position indicator) をセットする。新たな位置 (バイト単位)
80
81 .I whence
82 で指定された位置に
83 .I offset
84 バイトを加えることによって与えられる。
85 .\"O If
86 .\"O .I whence
87 .\"O is set to
88 .\"O .BR SEEK_SET ,
89 .\"O .BR SEEK_CUR ,
90 .\"O or
91 .\"O .BR SEEK_END ,
92 .\"O the offset is relative to the start of the file, the current position
93 .\"O indicator, or end-of-file, respectively.
94 .\"O A successful call to the
95 .\"O .BR fseek ()
96 .\"O function clears the end-of-file indicator for the stream and undoes
97 .\"O any effects of the
98 .\"O .BR ungetc (3)
99 .\"O function on the same stream.
100 .I whence
101
102 .BR SEEK_SET ,
103 .BR SEEK_CUR ,
104 .B SEEK_END
105 のどれかになっている場合は、それぞれファイルの先頭、現在の位置表示子、
106 ファイルの末尾からのオフセットが取られる。
107 .BR fseek ()
108 関数の呼び出しが成功すると、ストリームの end-of-file 表示子は
109 クリアされ、それまでに
110 .BR ungetc (3)
111 関数で戻したデータはなかったことになる。
112 .PP
113 .\"O The
114 .\"O .BR ftell ()
115 .\"O function obtains the current value of the file position indicator for the
116 .\"O stream pointed to by
117 .\"O .IR stream .
118 .BR ftell ()
119 関数は
120 .I stream
121 によって指定されたストリームにおける、ファイル位置表示子
122 の現時点での値を与える。
123 .PP
124 .\"O The
125 .\"O .BR rewind ()
126 .\"O function sets the file position indicator for the stream pointed to by
127 .\"O .I stream
128 .\"O to the beginning of the file.
129 .\"O It is equivalent to:
130 .BR rewind ()
131 関数は
132 .I stream
133 によって指定されたストリームにおいて、ファイル位置表示子
134 をファイルの先頭にセットする。この関数は以下と等価である。
135 .PP
136 .RS
137 (void) fseek(stream, 0L, SEEK_SET)
138 .RE
139 .PP
140 .\"O except that the error indicator for the stream is also cleared (see
141 .\"O .BR clearerr (3)).
142 ただし
143 .BR rewind ()
144 ではストリームに対するエラー表示子 (error indicator) も同時に
145 クリアされる (
146 .BR clearerr (3)
147 を見よ)。
148 .PP
149 .\"O The
150 .\"O .BR fgetpos ()
151 .\"O and
152 .\"O .BR fsetpos ()
153 .\"O functions are alternate interfaces equivalent to
154 .\"O .BR ftell ()
155 .\"O and
156 .\"O .BR fseek ()
157 .\"O (with whence set to
158 .\"O .BR SEEK_SET ),
159 .\"O setting and storing the current value of the file offset into or from the
160 .\"O object referenced by
161 .\"O .IR pos .
162 .BR fgetpos ()
163 関数と
164 .BR fsetpos ()
165 関数は、それぞれ
166 .BR ftell ()
167
168 .BR fseek ()
169
170 .I whence
171
172 .B SEEK_SET
173 を指定した場合と同様の機能を、異なるインターフェースで提供する。
174 .BR fgetpos ()
175 はファイルオフセットの現在の値を
176 .I pos
177 が参照するオブジェクトに保存し、
178 .BR fsetpos ()
179 はファイルオフセットを
180 .I pos
181 に設定する。
182 .\"O On some non-UNIX systems an
183 .\"O .I fpos_t
184 .\"O object may be a complex object and these routines may be the only way to
185 .\"O portably reposition a text stream.
186 UNIX 以外のシステムにおいては、
187 .I fpos_t
188 が構造体などの複雑なオブジェクトになっていて、これらのルーチンがテキス
189 トストリームでファイル位置を変更する方法のうち、移植性のある唯一のもの
190 になっている場合もある。
191 .\"O .SH "RETURN VALUES"
192 .SH 返り値
193 .\"O The
194 .\"O .BR rewind ()
195 .\"O function returns no value.
196 .\"O Upon successful completion,
197 .\"O .BR fgetpos (),
198 .\"O .BR fseek (),
199 .\"O .BR fsetpos ()
200 .\"O return 0,
201 .\"O and
202 .\"O .BR ftell ()
203 .\"O returns the current offset.
204 .\"O Otherwise, \-1 is returned and
205 .\"O .I errno
206 .\"O is set to indicate the error.
207 .BR rewind ()
208 は返り値を持たない。
209 .BR fgetpos (),
210 .BR fseek (),
211 .BR fsetpos ()
212 は成功すると 0 を返す。
213 .BR ftell ()
214 は現在のオフセットを返す。失敗した場合は返り値は \-1 となり、
215 .I errno
216 にエラーを示す値がセットされる。
217 .\"O .SH ERRORS
218 .SH エラー
219 .TP
220 .B EBADF
221 .\"O The
222 .\"O .I stream
223 .\"O specified is not a seekable stream.
224 指定した
225 .I stream
226 がシークできない。
227 .TP
228 .B EINVAL
229 .\"O The
230 .\"O .I whence
231 .\"O argument to
232 .\"O .BR fseek ()
233 .\"O was not
234 .\"O .BR SEEK_SET ,
235 .\"O .BR SEEK_END ,
236 .\"O or
237 .\"O .BR SEEK_CUR .
238 .BR fseek ()
239 関数に対して与えた
240 .I whence
241 引数が
242 .BR SEEK_SET ,
243 .BR SEEK_END ,
244 .B SEEK_CUR
245 以外の値であった。
246 .PP
247 .\"O The function
248 .\"O .BR fgetpos (),
249 .\"O .BR fseek (),
250 .\"O .BR fsetpos (),
251 .\"O and
252 .\"O .BR ftell ()
253 .\"O may also fail and set
254 .\"O .I errno
255 .\"O for any of the errors specified for the routines
256 .\"O .BR fflush (3),
257 .\"O .BR fstat (2),
258 .\"O .BR lseek (2),
259 .\"O and
260 .\"O .BR malloc (3).
261 .BR fgetpos (),
262 .BR fseek (),
263 .BR fsetpos (),
264 .BR ftell ()
265 は、それぞれ
266 .BR fflush (3),
267 .BR fstat (2),
268 .BR lseek (2),
269 .BR malloc (3)
270 などのルーチンを呼び出す際に失敗する可能性がある。この場合は
271 それぞれ対応した
272 .I errno
273 が設定される。
274 .\"O .SH STANDARDS
275 .\"O The
276 .\"O .BR fgetpos (),
277 .\"O .BR fsetpos (),
278 .\"O .BR fseek (),
279 .\"O .BR ftell (),
280 .\"O and
281 .\"O .BR rewind ()
282 .\"O functions conform to ANSI C3.159-1989 (``ANSI C'').
283 .SH 準拠
284 C89, C99.
285 .\"O .SH "SEE ALSO"
286 .SH 関連項目
287 .BR lseek (2),
288 .BR fseeko (3)