fc733ebccd
This section is based on catpages contributed by Mainichi Communications, Inc. Translated by: MYCOM team Converted by: Japanese Online Manual Project <man-jp@jp.FreeBSD.ORG> Submitted by: Kazuo Horikawa <k-horik@yk.rim.or.jp>
165 lines
4.4 KiB
Groff
165 lines
4.4 KiB
Groff
.\" Copyright (c) 1983, 1991, 1993
|
||
.\" The Regents of the University of California. All rights reserved.
|
||
.\"
|
||
.\" 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.
|
||
.\"
|
||
.\" @(#)directory.3 8.1 (Berkeley) 6/4/93
|
||
.\"
|
||
.Dd June 4, 1993
|
||
.Dt DIRECTORY 3
|
||
.Os BSD 4.2
|
||
.Sh ̾¾Î
|
||
.Nm opendir ,
|
||
.Nm readdir ,
|
||
.Nm telldir ,
|
||
.Nm seekdir ,
|
||
.Nm rewinddir ,
|
||
.Nm closedir ,
|
||
.Nm dirfd
|
||
.Nd ¥Ç¥£¥ì¥¯¥È¥êÁàºî
|
||
.Sh ½ñ¼°
|
||
.Fd #include <sys/types.h>
|
||
.Fd #include <dirent.h>
|
||
.Ft DIR *
|
||
.Fn opendir "const char *filename"
|
||
.Ft struct dirent *
|
||
.Fn readdir "DIR *dirp"
|
||
.Ft long
|
||
.Fn telldir "const DIR *dirp"
|
||
.Ft void
|
||
.Fn seekdir "DIR *dirp" "long loc"
|
||
.Ft void
|
||
.Fn rewinddir "DIR *dirp"
|
||
.Ft int
|
||
.Fn closedir "DIR *dirp"
|
||
.Ft int
|
||
.Fn dirfd "DIR *dirp"
|
||
.Sh ²òÀâ
|
||
.Fn opendir
|
||
´Ø¿ô¤Ï¡¢
|
||
.Fa filename
|
||
¤Ç»Ø̾¤µ¤ì¤¿¥Ç¥£¥ì¥¯¥È¥ê¤ò³«¤¡¢
|
||
.Em ¥Ç¥£¥ì¥¯¥È¥ê¥¹¥È¥ê¡¼¥à
|
||
¤ò¤½¤ì¤ËÂбþ¤µ¤»¡¢¸å³¤ÎÁàºî¤Ç¤Î
|
||
.Em ¥Ç¥£¥ì¥¯¥È¥ê¥¹¥È¥ê¡¼¥à
|
||
¤ò¼±Ê̤¹¤ë¤Î¤Ë»ÈÍѤ¹¤ë¥Ý¥¤¥ó¥¿¤òÊÖ¤·¤Þ¤¹¡£
|
||
.Fa filename
|
||
¤Ë
|
||
¥¢¥¯¥»¥¹¤Ç¤¤Ê¤¤¾ì¹ç¡¢¤Þ¤¿¤Ï¤¹¤Ù¤Æ¤Î¤â¤Î¤òÊÝ»ý¤¹¤ë¤Î¤Ë½½Ê¬¤Ê¥á¥â¥ê¤ò
|
||
.Xr malloc 3
|
||
¤Ç¤¤Ê¤¤¾ì¹ç¤Ï¡¢¥Ý¥¤¥ó¥¿
|
||
.Dv NULL
|
||
¤¬ÊÖ¤µ¤ì¤Þ¤¹¡£
|
||
.Pp
|
||
.Fn readdir
|
||
´Ø¿ô¤Ï¡¢¼¡¤Î¥Ç¥£¥ì¥¯¥È¥ê¥¨¥ó¥È¥ê¤ò»Ø¤¹¥Ý¥¤¥ó¥¿¤òÊÖ¤·¤Þ¤¹¡£¤³¤Î
|
||
´Ø¿ô¤Ï¡¢¥Ç¥£¥ì¥¯¥È¥ê¤ÎËöÈø¤ËÅþ㤹¤ë¤«¡¢¤Þ¤¿¤Ï̵¸ú¤Ê
|
||
.Fn seekdir
|
||
Áàºî¤ò
|
||
¸¡½Ð¤¹¤ë¤È
|
||
.Dv NULL
|
||
¤òÊÖ¤·¤Þ¤¹¡£
|
||
.Pp
|
||
.Fn telldir
|
||
´Ø¿ô¤Ï¡¢Ì¾Á°¤ÎÉÕ¤¤¤¿
|
||
.Em ¥Ç¥£¥ì¥¯¥È¥ê¥¹¥È¥ê¡¼¥à
|
||
¤ËÂбþ¤¹¤ë¸½ºß¤Î°ÌÃÖ¤òÊÖ¤·¤Þ¤¹¡£
|
||
.Fn telldir
|
||
¤¬ÊÖ¤¹Ãͤ¬Îɤ¤¤Î¤Ï¡¢ÇÉÀ¸¤µ¤»¤é¤ì¤ë¸µ¤È¤Ê¤Ã¤¿
|
||
.Dv DIR
|
||
¥Ý¥¤¥ó¥¿
|
||
.Fa dirp
|
||
¤Î¼÷Ì¿¤Î´Ö¤À¤±¤Ç¤¹¡£¥Ç¥£¥ì¥¯¥È¥ê¤¬ÊĤ¸¤é¤ìºÆ¤Ó³«¤«¤ì¤ë¤È¡¢
|
||
.Fn telldir
|
||
¤¬ÊÖ¤·¤¿°ÊÁ°¤ÎÃͤϤâ¤Ï¤ä͸ú¤Ç¤Ï¤¢¤ê¤Þ¤»¤ó¡£
|
||
.Pp
|
||
.Fn seekdir
|
||
´Ø¿ô¤Ï¡¢
|
||
.Em ¥Ç¥£¥ì¥¯¥È¥ê¥¹¥È¥ê¡¼¥à
|
||
¤Ø¤Î¼¡¤Î
|
||
.Fn readdir
|
||
Áàºî¤Î°ÌÃÖ¤òÀßÄꤷ¤Þ¤¹¡£¿·¤·¤¤°ÌÃ֤ϡ¢
|
||
.Fn telldir
|
||
Áàºî¤¬¼Â¹Ô¤µ¤ì¤¿¤È¤¤Î
|
||
.Em ¥Ç¥£¥ì¥¯¥È¥ê¥¹¥È¥ê¡¼¥à
|
||
¤ÈÂбþÉÕ¤±¤é¤ì¤¿¤â¤Î¤ËÌá¤ê¤Þ¤¹¡£
|
||
.Pp
|
||
.Fn rewinddir
|
||
´Ø¿ô¤Ï¡¢Ì¾Á°¤ÎÉÕ¤¤¤¿
|
||
.Em ¥Ç¥£¥ì¥¯¥È¥ê¥¹¥È¥ê¡¼¥à
|
||
¤Î°ÌÃÖ¤ò¥Ç¥£¥ì¥¯¥È¥ê¤ÎÀèƬ¤Ë¥ê¥»¥Ã¥È¤·¤Þ¤¹¡£
|
||
.Pp
|
||
.Fn closedir
|
||
´Ø¿ô¤Ï¡¢Ì¾Á°¤ÎÉÕ¤¤¤¿
|
||
.Em ¥Ç¥£¥ì¥¯¥È¥ê¥¹¥È¥ê¡¼¥à
|
||
¤òÊĤ¸¡¢
|
||
.Fa dirp
|
||
¥Ý¥¤¥ó¥¿¤ËÂбþ¤¹¤ë¹½Â¤¤ò²òÊü¤·¡¢½èÍý¤¬À®¸ù¤·¤¿¾ì¹ç¤Ï 0 ¤òÊÖ¤·¤Þ¤¹¡£
|
||
½èÍý¤¬¼ºÇÔ¤¹¤ë¤È¡¢\-1 ¤¬ÊÖ¤µ¤ì¡¢¥°¥í¡¼¥Ð¥ëÊÑ¿ô
|
||
.Va errno
|
||
¤¬ÀßÄꤵ¤ì¤Æ¥¨¥é¡¼¤ò¼¨¤¹¤è¤¦¤Ë¤Ê¤ê¤Þ¤¹¡£
|
||
.Pp
|
||
.Fn dirfd
|
||
´Ø¿ô¤Ï¡¢Ì¾Á°¤ÎÉÕ¤¤¤¿
|
||
.Em ¥Ç¥£¥ì¥¯¥È¥ê¥¹¥È¥ê¡¼¥à
|
||
¤ËÂбþ¤¹¤ëÀ°¿ô¥Õ¥¡¥¤¥ëµ½Ò»Ò¤òÊÖ¤·¤Þ¤¹¡£
|
||
.Xr open 2
|
||
¤ò»²¾È¤·¤Æ¤¯¤À¤µ¤¤¡£
|
||
.Pp
|
||
¥Ç¥£¥ì¥¯¥È¥ê¤Ç¥¨¥ó¥È¥ê¡Öname¡×¤ò¸¡º÷¤¹¤ë¥µ¥ó¥×¥ë¥³¡¼¥É¤Ï¼¡¤Î¤È¤ª¤ê¤Ç¤¹¡£
|
||
.Bd -literal -offset indent
|
||
len = strlen(name);
|
||
dirp = opendir(".");
|
||
while ((dp = readdir(dirp)) != NULL)
|
||
if (dp->d_namlen == len && !strcmp(dp->d_name, name)) {
|
||
(void)closedir(dirp);
|
||
return FOUND;
|
||
}
|
||
(void)closedir(dirp);
|
||
return NOT_FOUND;
|
||
.Pp
|
||
.Sh ´ØÏ¢¹àÌÜ
|
||
.Xr close 2 ,
|
||
.Xr lseek 2 ,
|
||
.Xr open 2 ,
|
||
.Xr read 2 ,
|
||
.Xr dir 5
|
||
.Pp
|
||
.Sh Îò»Ë
|
||
.Fn opendir ,
|
||
.Fn readdir ,
|
||
.Fn telldir ,
|
||
.Fn seekdir ,
|
||
.Fn rewinddir ,
|
||
.Fn closedir ,
|
||
¤ª¤è¤Ó
|
||
.Fn dirfd
|
||
¤Î³Æ´Ø¿ô¤Ï
|
||
.Bx 4.2
|
||
¤Ç¸½¤ì¤Þ¤·¤¿¡£
|