.\" Copyright (C) 1993 David Metcalfe (david@prism.demon.co.uk) .\" .\" %%%LICENSE_START(VERBATIM) .\" Permission is granted to make and distribute verbatim copies of this .\" manual provided the copyright notice and this permission notice are .\" preserved on all copies. .\" .\" Permission is granted to copy and distribute modified versions of this .\" manual under the conditions for verbatim copying, provided that the .\" entire resulting derived work is distributed under the terms of a .\" permission notice identical to this one. .\" .\" Since the Linux kernel and libraries are constantly changing, this .\" manual page may be incorrect or out-of-date. The author(s) assume no .\" responsibility for errors or omissions, or for damages resulting from .\" the use of the information contained herein. The author(s) may not .\" have taken the same level of care in the production of this manual, .\" which is licensed free of charge, as they might when working .\" professionally. .\" .\" Formatted or processed versions of this manual, if unaccompanied by .\" the source, must acknowledge the copyright and authors of this work. .\" %%%LICENSE_END .\" .\" References consulted: .\" Linux libc source code .\" Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991) .\" 386BSD man pages .\" Modified Sat Jul 24 18:46:01 1993 by Rik Faith (faith@cs.unc.edu) .\" Modified 11 June 1995 by Andries Brouwer (aeb@cwi.nl) .\" 2007-07-30 Ulrich Drepper : document fdopendir(). .\"******************************************************************* .\" .\" This file was generated with po4a. Translate the source file. .\" .\"******************************************************************* .\" .\" Japanese Version Copyright (c) 1997 Seiichi Yoshida .\" all rights reserved. .\" Translated Fri Feb 14 14:53:20 JST 1997 .\" by Seiichi Yoshida .\" Updated & Modified Thu Feb 17 00:37:46 JST 2005 .\" by Yuichi SATO .\" .TH OPENDIR 3 2010\-06\-20 GNU "Linux Programmer's Manual" .SH 名前 opendir, fdopendir \- ディレクトリをオープンする .SH 書式 .nf \fB#include \fP .br \fB#include \fP .sp \fBDIR *opendir(const char *\fP\fIname\fP\fB);\fP \fBDIR *fdopendir(int \fP\fIfd\fP\fB);\fP .fi .sp .in -4n glibc 向けの機能検査マクロの要件 (\fBfeature_test_macros\fP(7) 参照): .in .sp \fBfdopendir\fP(): .PD 0 .ad l .RS 4 .TP 4 glibc 2.10 以降: _XOPEN_SOURCE\ >=\ 700 || _POSIX_C_SOURCE\ >=\ 200809L .TP glibc 2.10 より前: _GNU_SOURCE .RE .ad .PD .SH 説明 \fBopendir\fP() 関数はディレクトリ \fIname\fP に対応する ディレクトリストリームをオープンし、そのストリームへのポインターを返す。 ストリームの位置はディレクトリの先頭のエントリーに設定される。 \fBfdopendir\fP() 関数は \fBopendir\fP() と同様だが、オープン済みのファイルディスクリプター \fIfd\fP により参照されるディレクトリに対する ディレクトリストリームを返す。 \fBfdopendir\fP() の呼び出しが成功した後は、 \fIfd\fP は実装の内部で使用される。アプリケーションは \fIfd\fP を他の場面で使用すべきではない。 .SH 返り値 関数 \fBopendir\fP() と \fBfdopendir\fP() はディレクトリストリームへのポインターを返す。 エラーの場合は、NULL が返されて、 \fIerrno\fP が適切に設定される。 .SH エラー .TP \fBEACCES\fP アクセス権限がない。 .TP \fBEBADF\fP \fIfd\fP が読み出し用にオープンされた、有効なファイルディスクリプターではない。 .TP \fBEMFILE\fP プロセスが使用中のファイルディスクリプターが多すぎる。 .TP \fBENFILE\fP システムでオープンされているファイルが多すぎる。 .TP \fBENOENT\fP ディレクトリが存在しないか、または \fIname\fP が空文字列である。 .TP \fBENOMEM\fP 操作を完了するのに十分なメモリーがない。 .TP \fBENOTDIR\fP \fIname\fP はディレクトリではない。 .SH バージョン \fBfdopendir\fP() は glibc 2.4 以降で利用可能である。 .SH 準拠 \fBopendir\fP() は SVr4 と 4.3BSD に存在し、 POSIX.1\-2001 で規定されている。 \fBfdopendir\fP() は POSIX.1\-2008 で規定されている。 .SH 注意 ディレクトリストリームに対応するファイルディスクリプターは \fBdirfd\fP(3) を使用して得ることができる。 \fBopendir\fP() 関数は、 \fIDIR *\fP の背後にあるファイルディスクリプターの close\-on\-exec フラグを設定する。 \fBfdopendir\fP() 関数は、ファイルディスクリプターの close\-on\-exec フラグの設定を変更しない。 \fBfdopendir\fP() の呼び出しが成功した際に、ファイルディスクリプター \fIfd\fP の close\-on\-exec を設定するかどうかは、 POSIX.1\-200x では規定されていない。 .SH 関連項目 \fBopen\fP(2), \fBclosedir\fP(3), \fBdirfd\fP(3), \fBreaddir\fP(3), \fBrewinddir\fP(3), \fBscandir\fP(3), \fBseekdir\fP(3), \fBtelldir\fP(3) .SH この文書について この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.79 の一部 である。プロジェクトの説明とバグ報告に関する情報は http://www.kernel.org/doc/man\-pages/ に書かれている。