.\" Copyright (c) 1990, 1991 The Regents of the University of California. .\" All rights reserved. .\" .\" This code is derived from software contributed to Berkeley by .\" Chris Torek and the American National Standards Committee X3, .\" on Information Processing Systems. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. All advertising materials mentioning features or use of this software .\" must display the following acknowledgement: .\" This product includes software developed by the University of .\" California, Berkeley and its contributors. .\" 4. Neither the name of the University nor the names of its contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" @(#)fseek.3 6.11 (Berkeley) 6/29/91 .\" .\" Converted for Linux, Mon Nov 29 15:22:01 1993, faith@cs.unc.edu .\" .\" .\" Japanese Version Copyright (c) 1998 NAKANO Takeo all rights reserved. .\" Translated Mon Apr 27 1998 by NAKANO Takeo .\" .\" WORD: file position indicator ファイル位置表示子 .\" WORD: error indicator エラー表示子 .\" .TH FSEEK 3 1993-11-29 "GNU" "Linux Programmer's Manual" .\"O .SH NAME .\"O fgetpos, fseek, fsetpos, ftell, rewind \- reposition a stream .SH 名前 fgetpos, fseek, fsetpos, ftell, rewind \- ストリームの位置を変更する .\"O .SH SYNOPSIS .SH 書式 .B #include .sp .BI "int fseek(FILE *" stream ", long " offset ", int " whence ); .BI "long ftell(FILE *" stream ); .BI "void rewind(FILE *" stream ); .BI "int fgetpos(FILE *" stream ", fpos_t *" pos ); .br .BI "int fsetpos(FILE *" stream ", fpos_t *" pos ); .\"O .SH DESCRIPTION .SH 説明 .\"O The .\"O .BR fseek () .\"O function sets the file position indicator for the stream pointed to by .\"O .IR stream . .\"O The new position, measured in bytes, is obtained by adding .\"O .I offset .\"O bytes to the position specified by .\"O .IR whence . .BR fseek () 関数は .I stream によって指定されたストリームにおいて、ファイル位置表示子 (file position indicator) をセットする。新たな位置 (バイト単位) は .I whence で指定された位置に .I offset バイトを加えることによって与えられる。 .\"O If .\"O .I whence .\"O is set to .\"O .BR SEEK_SET , .\"O .BR SEEK_CUR , .\"O or .\"O .BR SEEK_END , .\"O the offset is relative to the start of the file, the current position .\"O indicator, or end-of-file, respectively. .\"O A successful call to the .\"O .BR fseek () .\"O function clears the end-of-file indicator for the stream and undoes .\"O any effects of the .\"O .BR ungetc (3) .\"O function on the same stream. .I whence が .BR SEEK_SET , .BR SEEK_CUR , .B SEEK_END のどれかになっている場合は、それぞれファイルの先頭、現在の位置表示子、 ファイルの末尾からのオフセットが取られる。 .BR fseek () 関数の呼び出しが成功すると、ストリームの end-of-file 表示子は クリアされ、それまでに .BR ungetc (3) 関数で戻したデータはなかったことになる。 .PP .\"O The .\"O .BR ftell () .\"O function obtains the current value of the file position indicator for the .\"O stream pointed to by .\"O .IR stream . .BR ftell () 関数は .I stream によって指定されたストリームにおける、ファイル位置表示子 の現時点での値を与える。 .PP .\"O The .\"O .BR rewind () .\"O function sets the file position indicator for the stream pointed to by .\"O .I stream .\"O to the beginning of the file. .\"O It is equivalent to: .BR rewind () 関数は .I stream によって指定されたストリームにおいて、ファイル位置表示子 をファイルの先頭にセットする。この関数は以下と等価である。 .PP .RS (void) fseek(stream, 0L, SEEK_SET) .RE .PP .\"O except that the error indicator for the stream is also cleared (see .\"O .BR clearerr (3)). ただし .BR rewind () ではストリームに対するエラー表示子 (error indicator) も同時に クリアされる ( .BR clearerr (3) を見よ)。 .PP .\"O The .\"O .BR fgetpos () .\"O and .\"O .BR fsetpos () .\"O functions are alternate interfaces equivalent to .\"O .BR ftell () .\"O and .\"O .BR fseek () .\"O (with whence set to .\"O .BR SEEK_SET ), .\"O setting and storing the current value of the file offset into or from the .\"O object referenced by .\"O .IR pos . .BR fgetpos () 関数と .BR fsetpos () 関数は、それぞれ .BR ftell () と .BR fseek () で .I whence に .B SEEK_SET を指定した場合と同様の機能を、異なるインターフェースで提供する。 .BR fgetpos () はファイルオフセットの現在の値を .I pos が参照するオブジェクトに保存し、 .BR fsetpos () はファイルオフセットを .I pos に設定する。 .\"O On some non-UNIX systems an .\"O .I fpos_t .\"O object may be a complex object and these routines may be the only way to .\"O portably reposition a text stream. UNIX 以外のシステムにおいては、 .I fpos_t が構造体などの複雑なオブジェクトになっていて、これらのルーチンがテキス トストリームでファイル位置を変更する方法のうち、移植性のある唯一のもの になっている場合もある。 .\"O .SH "RETURN VALUES" .SH 返り値 .\"O The .\"O .BR rewind () .\"O function returns no value. .\"O Upon successful completion, .\"O .BR fgetpos (), .\"O .BR fseek (), .\"O .BR fsetpos () .\"O return 0, .\"O and .\"O .BR ftell () .\"O returns the current offset. .\"O Otherwise, \-1 is returned and .\"O .I errno .\"O is set to indicate the error. .BR rewind () は返り値を持たない。 .BR fgetpos (), .BR fseek (), .BR fsetpos () は成功すると 0 を返す。 .BR ftell () は現在のオフセットを返す。失敗した場合は返り値は \-1 となり、 .I errno にエラーを示す値がセットされる。 .\"O .SH ERRORS .SH エラー .TP .B EBADF .\"O The .\"O .I stream .\"O specified is not a seekable stream. 指定した .I stream がシークできない。 .TP .B EINVAL .\"O The .\"O .I whence .\"O argument to .\"O .BR fseek () .\"O was not .\"O .BR SEEK_SET , .\"O .BR SEEK_END , .\"O or .\"O .BR SEEK_CUR . .BR fseek () 関数に対して与えた .I whence 引数が .BR SEEK_SET , .BR SEEK_END , .B SEEK_CUR 以外の値であった。 .PP .\"O The function .\"O .BR fgetpos (), .\"O .BR fseek (), .\"O .BR fsetpos (), .\"O and .\"O .BR ftell () .\"O may also fail and set .\"O .I errno .\"O for any of the errors specified for the routines .\"O .BR fflush (3), .\"O .BR fstat (2), .\"O .BR lseek (2), .\"O and .\"O .BR malloc (3). .BR fgetpos (), .BR fseek (), .BR fsetpos (), .BR ftell () は、それぞれ .BR fflush (3), .BR fstat (2), .BR lseek (2), .BR malloc (3) などのルーチンを呼び出す際に失敗する可能性がある。この場合は それぞれ対応した .I errno が設定される。 .\"O .SH STANDARDS .\"O The .\"O .BR fgetpos (), .\"O .BR fsetpos (), .\"O .BR fseek (), .\"O .BR ftell (), .\"O and .\"O .BR rewind () .\"O functions conform to ANSI C3.159-1989 (``ANSI C''). .SH 準拠 C89, C99. .\"O .SH "SEE ALSO" .SH 関連項目 .BR lseek (2), .BR fseeko (3)