opendirのヘルプ・マニュアル
日本語 英語
opendir --help
man opendir
OPENDIR(3) Linux Programmer’s Manual OPENDIR(3)
名前
opendir, fdopendir - ディレクトリをオープンする
書式
#include
#include
DIR *opendir(const char *name);
DIR *fdopendir(int fd);
説明
opendir() 関数はディレクトリ name に対応するディレクトリストリームをオ
ープンし、そのストリームへのポインタを返す。ストリームの位置はディレ ク
トリの先頭のエントリに設定される。
fdopendir() は opendir() と同様だが、オープン済みのファイルディスクリプ
タ fd により参照されるディレクトリに対するディレクトリストリームを返 す
。 fdopendir() の呼び出しが成功した後は、 fd は実装の内部で使用される。
アプリケーションは fd を他の場面で使用すべきではない。
返り値
関数 opendir() と fdopendir() はディレクトリストリームへのポインタを 返
す。エラーの場合は、NULL が返されて、 errno が適切に設定される。
エラー
EACCES アクセス権限がない。
EBADF fd が読み出し用にオープンされた、有効なファイルディスクリプタで
はない。
EMFILE プロセスが使用中のファイルディスクリプタが多すぎる。
ENFILE システムでオープンされているファイルが多すぎる。
ENOENT ディレクトリが存在しないか、または name が空文字列である。
ENOMEM 命令を実行するのに充分なメモリがない。
ENOTDIR
name はディレクトリではない。
バージョン
fdopendir() は glibc 2.4 以降で利用可能である。
準拠
opendir() は SVr4 と 4.3BSD に存在し、 POSIX.1-2001 で規定されている 。
fdopendir() は POSIX.1-2008 で規定されている。
注意
デ ィレクトリストリームに対応するファイルディスクリプタは dirfd(3) を使
用して得ることができる。
opendir() 関数は、 DIR * の背後にあるファイルディスクリプタの close-on-
exec フ ラグを設定する。 fdopendir() 関数は、ファイルディスクリプタの
close-on-exec フラグの設定を変更しない。 fdopendir() の呼び出しが成功し
た際に、ファイルディスクリプタ fd の close-on-exec を設定するかどうかは
、 POSIX.1-200x では規定されていない。
関連項目
open(2), closedir(3), dirfd(3), readdir(3), rewinddir(3), scandir(3),
seekdir(3), telldir(3)
2008-08-06 OPENDIR(3)
OPENDIR(3) Linux Programmer’s Manual OPENDIR(3)
NAME
opendir, fdopendir - open a directory
SYNOPSIS
#include
#include
DIR *opendir(const char *name);
DIR *fdopendir(int fd);
DESCRIPTION
The opendir() function opens a directory stream corresponding to the
directory name, and returns a pointer to the directory stream. The
stream is positioned at the first entry in the directory.
The fdopendir() is like opendir(), but returns a directory stream for
the directory referred to by the open file descriptor fd. After a suc-
cessful call to fdopendir(), fd is used internally by the implementa-
tion, and should not otherwise be used by the application.
RETURN VALUE
The opendir() and fdopendir() functions return a pointer to the direc-
tory stream. On error, NULL is returned, and errno is set appropri-
ately.
ERRORS
EACCES Permission denied.
EBADF fd is not a valid file descriptor opened for reading.
EMFILE Too many file descriptors in use by process.
ENFILE Too many files are currently open in the system.
ENOENT Directory does not exist, or name is an empty string.
ENOMEM Insufficient memory to complete the operation.
ENOTDIR
name is not a directory.
VERSIONS
fdopendir() is available in glibc since version 2.4.
CONFORMING TO
opendir() is present on SVr4, 4.3BSD, and specified in POSIX.1-2001.
fdopendir() is specified in POSIX.1-2008.
NOTES
The underlying file descriptor of the directory stream can be obtained
using dirfd(3).
The opendir() function sets the close-on-exec flag for the file
descriptor underlying the DIR *. The fdopendir() function leaves the
setting of the close-on-exec flag unchanged for the file descriptor,
fd. POSIX.1-200x leaves it unspecified whether a successful call to
fdopendir() will set the close-on-exec flag for the file descriptor,
fd.
SEE ALSO
open(2), closedir(3), dirfd(3), readdir(3), rewinddir(3), scandir(3),
seekdir(3), telldir(3)
COLOPHON
This page is part of release 3.22 of the Linux man-pages project. A
description of the project, and information about reporting bugs, can
be found at http://www.kernel.org/doc/man-pages/.
GNU 2008-08-06 OPENDIR(3)