OSDN Git Service

Release locale related pages
[linuxjm/LDP_man-pages.git] / release / man3 / scandir.3
index 3fd933b..c6117d7 100644 (file)
@@ -1,5 +1,6 @@
 .\" 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.
@@ -19,6 +20,7 @@
 .\"
 .\" 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
 .\" Modified Sun Sep 24 20:15:46 2000 by aeb, following Petter Reinholdtsen.
 .\" Modified 2001-12-26 by aeb, following Joey. Added versionsort.
 .\"
-.\" FIXME glibc 2.15 adds scandirat()
+.\" The pieces on scandirat(3) were copyright and licensed as follows.
+.\"
+.\" Copyright (c) 2012, Mark R. Bannister <cambridge@users.sourceforge.net>
+.\"        based on text in mkfifoat.3 Copyright (c) 2006, Michael Kerrisk
+.\"
+.\" %%%LICENSE_START(GPLv2+_DOC_FULL)
+.\" This is free documentation; you can redistribute it and/or
+.\" modify it under the terms of the GNU General Public License as
+.\" published by the Free Software Foundation; either version 2 of
+.\" the License, or (at your option) any later version.
+.\"
+.\" The GNU General Public License's references to "object code"
+.\" and "executables" are to be interpreted as the output of any
+.\" document formatting or typesetting system, including
+.\" intermediate and printed output.
+.\"
+.\" This manual is distributed in the hope that it will be useful,
+.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
+.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+.\" GNU General Public License for more details.
+.\"
+.\" You should have received a copy of the GNU General Public
+.\" License along with this manual; if not, see
+.\" <http://www.gnu.org/licenses/>.
+.\" %%%LICENSE_END
+.\"
+.\"*******************************************************************
+.\"
+.\" This file was generated with po4a. Translate the source file.
+.\"
+.\"*******************************************************************
 .\"
 .\" Japanese Version Copyright (c) 1998 Hiroaki Nagoya all rights reserved.
 .\" Translated Thu May 28 1998 by Hiroaki Nagoya <nagoya@is.titech.ac.jp>
 .\" Updated & Modified Sun Jan 16 08:12:04 JST 2005
 .\"         by Yuichi SATO <ysato444@yahoo.co.jp>
 .\"
-.TH SCANDIR 3  2011-09-08 "GNU" "Linux Programmer's Manual"
-.SH Ì¾Á°
-scandir, alphasort, versionsort \- ¥Ç¥£¥ì¥¯¥È¥ê¤òÁöºº¤¹¤ë
-.SH ½ñ¼°
+.TH SCANDIR 3 2014\-05\-28 GNU "Linux Programmer's Manual"
+.SH 名前
+scandir, scandirat, alphasort, versionsort \- ディレクトリを走査する
+.SH 書式
 .nf
-.B #include <dirent.h>
+\fB#include <dirent.h>\fP
 .sp
-.BI "int scandir(const char *" dirp ", struct dirent ***" namelist ,
+\fBint scandir(const char *\fP\fIdirp\fP\fB, struct dirent ***\fP\fInamelist\fP\fB,\fP
 .RS
-.BI "int (*" filter ")(const struct dirent *),"
-.BI "int (*" compar ")(const struct dirent **, const struct dirent **));"
+\fBint (*\fP\fIfilter\fP\fB)(const struct dirent *),\fP
+\fBint (*\fP\fIcompar\fP\fB)(const struct dirent **, const struct dirent **));\fP
 .RE
 .sp
-.BI "int alphasort(const void *" a ", const void *" b );
+\fBint alphasort(const struct dirent **\fP\fIa\fP\fB, const struct dirent **\fP\fIb\fP\fB);\fP
 .sp
-.BI "int versionsort(const void *" a ", const void *" b );
+\fBint versionsort(const struct dirent **\fP\fIa\fP\fB, const struct dirent **\fP\fIb\fP\fB);\fP
+
+\fB#include <fcntl.h>\fP          /* AT_* 定数の定義 */
+\fB#include <dirent.h>\fP
+.sp
+.fi
+\fBint scandirat(int \fP\fIdirfd\fP\fB, const char *\fP\fIdirp\fP\fB,\fP \fBstruct dirent
+***\fP\fInamelist\fP\fB,\fP
+.nf
+.RS
+\fBint (*\fP\fIfilter\fP\fB)(const struct dirent *),\fP
+\fBint (*\fP\fIcompar\fP\fB)(const struct dirent **, const struct dirent **));\fP
+.RE
 .fi
 .sp
 .in -4n
-glibc ¸þ¤±¤Îµ¡Ç½¸¡ºº¥Þ¥¯¥í¤ÎÍ×·ï
-.RB ( feature_test_macros (7)
-»²¾È):
+glibc 向けの機能検査マクロの要件 (\fBfeature_test_macros\fP(7)  参照):
 .in
 .sp
-.BR scandir (),
-.BR alphasort ():
+\fBscandir\fP(), \fBalphasort\fP():
+.br
+.RS 4
+.PD 0
+.ad b
 _BSD_SOURCE || _SVID_SOURCE
 .br
-.BR versionsort ():
-_GNU_SOURCE
-.SH ÀâÌÀ
-´Ø¿ô
-.BR scandir ()
-¤Ï¥Ç¥£¥ì¥¯¥È¥ê \fIdirp\fP ¤òÁöºº¤·¡¢
-¥Ç¥£¥ì¥¯¥È¥ê¤Î³Æ¥¨¥ó¥È¥ê¤ò°ú¤­¿ô¤È¤·¤Æ
-.BR filter ()
-¤ò¸Æ¤Ó½Ð¤¹¡£
-.BR filter ()
-¤¬ 0 °Ê³°¤ÎÃͤòÊÖ¤¹¥¨¥ó¥È¥ê¤Ï
-.BR malloc (3)
-¤Ë¤è¤Ã¤Æ
-³ÎÊݤµ¤ì¤¿Ê¸»úÎó¤ËÊݸ¤µ¤ì¡¢Èæ³Ó´Ø¿ô
-.BR compar ()
-¤òÍѤ¤¤Æ
-.BR qsort (3)
-¤Ë¤è¤ê¥½¡¼¥È¤µ¤ì¡¢
-.BR malloc (3)
-¤Ë¤è¤ê³ÎÊݤµ¤ì¤¿ÇÛÎó
-\fInamelist\fP ¤Ë¤Þ¤È¤á¤é¤ì¤ë¡£
-\fIfilter\fP ¤¬ NULL ¤Ê¤é¤Ð¡¢¤¹¤Ù¤Æ¤Î¥¨¥ó¥È¥ê¤¬ÁªÂò¤µ¤ì¤ë¡£
-.LP
-Èæ³Ó´Ø¿ô
-.IR compar ()
-¤Ë¤Ï
-.BR alphasort ()
-´Ø¿ô¤È
-.BR versionsort ()
-´Ø¿ô¤ò»È¤¦¤³¤È¤¬¤Ç¤­¤ë¡£
-.BR alphasort ()
-¤Ï
-.BR strcoll (3)
-¤òÍѤ¤¤Æ¥Ç¥£¥ì¥¯¥È¥ê¥¨¥ó¥È¥ê¤ò¥½¡¼¥È¤·¡¢
-.BR versionsort ()
-¤Ïʸ»úÎó \fI(*a)\->d_name\fP ¤È \fI(*b)\->d_name\fP ¤ËÂФ·¤Æ
-.BR strverscmp (3)
-¤òÍѤ¤¤ë¡£
-.SH ÊÖ¤êÃÍ
-´Ø¿ô
-.BR scandir ()
-¤ÏÁªÂò¤µ¤ì¤¿¥¨¥ó¥È¥ê¤Î¿ô¤«¡¢
-(¥¨¥é¡¼¤¬È¯À¸¤·¤¿¾ì¹ç) \-1 ¤òÊÖ¤¹¡£
-.PP
-´Ø¿ô
-.BR alphasort ()
-¤È
-.BR versionsort ()
-¤Ï 1 ÈÖÌܤΰú¤­¿ô¤¬ 2 ÈÖÌܤΰú¤­¿ô¤ËÂФ·¤Æ¡¢
-[¾®¤µ¤¤/Åù¤·¤¤/Â礭¤¤] ¤«¤Ë±þ¤¸¤Æ¡¢0 ¤è¤ê [¾®¤µ¤¤/Åù¤·¤¤/Â礭¤¤] ÃͤòÊÖ¤¹¡£
-.SH ¥¨¥é¡¼
-.TP
-.B ENOENT
-\fIdirp\fR ¤Ç»ØÄꤵ¤ì¤¿¥Ñ¥¹¤¬Â¸ºß¤·¤Ê¤¤¡£
-.TP
-.B ENOMEM
-Æ°ºî¤ò´°¿ë¤¹¤ë¤Ë¤Ï¥á¥â¥ê¤¬Â­¤ê¤Ê¤¤¡£
-.TP
-.B ENOTDIR
-\fIdirp\fR ¤Ç»ØÄꤵ¤ì¤¿¥Ñ¥¹¤¬¥Ç¥£¥ì¥¯¥È¥ê¤Ç¤Ï¤Ê¤¤¡£
-.SH ¥Ð¡¼¥¸¥ç¥ó
-.BR versionsort ()
-¤Ï¡¢glibc ¥Ð¡¼¥¸¥ç¥ó 2.1 ¤ÇÄɲ䵤줿¡£
-.SH ½àµò
-.BR alphasort ()
-¤È
-.BR scandir ()
-¤Ï POSIX.1-2008 ¤Çµ¬Äꤵ¤ì¤Æ¤ª¤ê¡¢¹­¤¯ÍøÍѲÄǽ¤Ç¤¢¤ë¡£
-.BR versionsort ()
-¤Ï GNU ³ÈÄ¥¤Ç¤¢¤ë¡£
-.LP
-´Ø¿ô
-.BR scandir ()
-¤È
-.BR alphasort ()
-¤Ï 4.3BSD ¤«¤é¼è¤êÆþ¤ì¤é¤ì¡¢Linux ¤Ç¤Ï libc4 ¤«¤é»ÈÍѲÄǽ¤Ë¤Ê¤Ã¤¿¡£
-libc4 ¤È libc5 ¤Ç¤Ï°Ê²¼¤Î¤è¤¦¤Ê¤â¤Ã¤È¾ÜºÙ¤Ê¥×¥í¥È¥¿¥¤¥×¤ò»È¤Ã¤Æ¤¤¤ë¡£
+|| /* glibc 2.10 以降: */
+.RS 4
+(_POSIX_C_SOURCE\ >=\ 200809L || _XOPEN_SOURCE\ >=\ 700)
+.RE
+.PD
+.RE
 .sp
-.nf
-    int alphasort(const struct dirent ** a,
-                  const struct dirent **b);
-.fi
+\fBversionsort\fP(): _GNU_SOURCE
 .sp
-¤·¤«¤· glibc 2.0 ¤Ç¤ÏÉÔÀµ³Î¤Ê BSD ¤Î¥×¥í¥È¥¿¥¤¥×¤ËÌá¤Ã¤¿¡£
+\fBscandirat\fP(): _GNU_SOURCE
+.SH 説明
+関数 \fBscandir\fP()  はディレクトリ \fIdirp\fP を走査し、 ディレクトリの各エントリを引き数として \fBfilter\fP()
+を呼び出す。 \fBfilter\fP()  が 0 以外の値を返すエントリは \fBmalloc\fP(3)  によって 確保された文字列に保存され、比較関数
+\fBcompar\fP()  を用いて \fBqsort\fP(3)  によりソートされ、 \fBmalloc\fP(3)  により確保された配列
+\fInamelist\fP にまとめられる。 \fIfilter\fP が NULL ならば、すべてのエントリが選択される。
 .LP
-´Ø¿ô
-.BR versionsort ()
-¤Ï GNU ¤Î³ÈÄ¥¤Ç¤¢¤ê¡¢glibc 2.1 °Ê¹ß¤Ç»ÈÍѲÄǽ¤Ç¤¢¤ë¡£
-.LP
-glibc 2.1 °Ê¹ß¤Ç¤Ï
-.BR alphasort ()
-¤Ï
-.BR strcoll (3)
-¤ò¸Æ¤Ó½Ð¤¹¡£
-.BR alphasort ()
-¤Ï°ÊÁ°¤Ï
-.BR strcmp (3)
-¤ò»È¤Ã¤Æ¤¤¤¿¡£
-.SH Îã
+比較関数 \fIcompar\fP()  には \fBalphasort\fP()  関数と \fBversionsort\fP()  関数を使うことができる。
+\fBalphasort\fP()  は \fBstrcoll\fP(3)  を用いてディレクトリエントリをソートし、 \fBversionsort\fP()  は文字列
+\fI(*a)\->d_name\fP と \fI(*b)\->d_name\fP に対して \fBstrverscmp\fP(3)  を用いる。
+.SS scandirat()
+\fBscandirat\fP() 関数は \fBscandir\fP() と全く同様の動作をする。差分についてはここで説明する。
+
+\fIdirp\fP で指定されたパス名が相対パスの場合、ファイルディスクリプタ \fIdirfd\fP が参照するディレクトリからの相対パスと解釈される
+(これに対して、\fBscandir\fP() の場合は、相対パス名は、呼び出したプロセスのカレントワーキングディレクトリからの相対パスと解釈される)。
+
+\fIdirp\fP が相対パスで \fIdirfd\fP が特別な値 \fBAT_FDCWD\fP の場合、 \fIdirp\fP は (\fBscandir\fP() と同様に)
+呼び出したプロセスのカレントワーキングディレクトリからの相対パスと解釈される。
+
+\fIdirp\fP が絶対パスの場合、\fIdirfd\fP は無視される。
+.PP
+\fBscandirat\fP() が必要な理由については \fBopenat\fP(2) を参照すること。
+.SH 返り値
+\fBscandir\fP() 関数は、選択されたディレクトリのエントリ数を返す。 エラーの場合、 \-1 を返し、 \fIerrno\fP
+にエラーの原因を示す値を設定する。
+.PP
+関数 \fBalphasort\fP()  と \fBversionsort\fP()  は 1 番目の引き数が 2 番目の引き数に対して、
+[小さい/等しい/大きい] かに応じて、0 より [小さい/等しい/大きい] 値を返す。
+.SH エラー
+.TP 
+\fBENOENT\fP
+\fIdirp\fP で指定されたパスが存在しない。
+.TP 
+\fBENOMEM\fP
+操作を完了するのに十分なメモリがない。
+.TP 
+\fBENOTDIR\fP
+\fIdirp\fP で指定されたパスがディレクトリではない。
+.PP
+\fBscandirat\fP() では追加で以下のエラーも発生する:
+.TP 
+\fBEBADF\fP
+\fIdirfd\fP が有効なファイルディスクリプタではない。
+.TP 
+\fBENOTDIR\fP
+\fIdirp\fP が相対パスで、\fIdirfd\fP がディレクトリ以外のファイルを参照している
+ファイルディスクリプタである。
+.SH バージョン
+\fBversionsort\fP()  は、glibc バージョン 2.1 で追加された。
+
+\fBscandirat\fP()  は glibc バージョン 2.15 で追加された。
+.SH 準拠
+\fBalphasort\fP(), \fBscandir\fP(): 4.3BSD, POSIX.1\-2008.
+
+.\" .LP
+.\" The functions
+.\" .BR scandir ()
+.\" and
+.\" .BR alphasort ()
+.\" are from 4.3BSD, and have been available under Linux since libc4.
+.\" Libc4 and libc5 use the more precise prototype
+.\" .sp
+.\" .nf
+.\"    int alphasort(const struct dirent ** a,
+.\"                  const struct dirent **b);
+.\" .fi
+.\" .sp
+.\" but glibc 2.0 returns to the imprecise BSD prototype.
+\fBversionsort\fP() と \fBscandirat\fP() は GNU 拡張である。
+.SH 注意
+glibc 2.1 以降では \fBalphasort\fP()  は \fBstrcoll\fP(3)  を呼び出す。 \fBalphasort\fP()  は以前は
+\fBstrcmp\fP(3)  を使っていた。
+.SH 例
 .nf
 #define _SVID_SOURCE
-/* ¥«¥ì¥ó¥È¥Ç¥£¥ì¥¯¥È¥ê¤Î¥Õ¥¡¥¤¥ë¤òµÕ½ç¤Ë½ÐÎϤ¹¤ë */
+/* カレントディレクトリのファイルを逆順に出力する */
 #include <dirent.h>
 
 int
@@ -178,7 +206,7 @@ main(void)
     struct dirent **namelist;
     int n;
 
-    n = scandir(".", &namelist, 0, alphasort);
+    n = scandir(".", &namelist, NULL, alphasort);
     if (n < 0)
         perror("scandir");
     else {
@@ -190,14 +218,11 @@ main(void)
     }
 }
 .fi
-.SH ´ØÏ¢¹àÌÜ
-.BR closedir (3),
-.BR fnmatch (3),
-.BR opendir (3),
-.BR readdir (3),
-.BR rewinddir (3),
-.BR seekdir (3),
-.BR strcmp (3),
-.BR strcoll (3),
-.BR strverscmp (3),
-.BR telldir (3)
+.SH 関連項目
+\fBclosedir\fP(3), \fBfnmatch\fP(3), \fBopendir\fP(3), \fBreaddir\fP(3),
+\fBrewinddir\fP(3), \fBseekdir\fP(3), \fBstrcmp\fP(3), \fBstrcoll\fP(3),
+\fBstrverscmp\fP(3), \fBtelldir\fP(3)
+.SH この文書について
+この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.78 の一部
+である。プロジェクトの説明とバグ報告に関する情報は
+http://www.kernel.org/doc/man\-pages/ に書かれている。