1 .\" Copyright (c) 1999 Andries Brouwer (aeb@cwi.nl)
3 .\" Permission is granted to make and distribute verbatim copies of this
4 .\" manual provided the copyright notice and this permission notice are
5 .\" preserved on all copies.
7 .\" Permission is granted to copy and distribute modified versions of this
8 .\" manual under the conditions for verbatim copying, provided that the
9 .\" entire resulting derived work is distributed under the terms of a
10 .\" permission notice identical to this one.
12 .\" Since the Linux kernel and libraries are constantly changing, this
13 .\" manual page may be incorrect or out-of-date. The author(s) assume no
14 .\" responsibility for errors or omissions, or for damages resulting from
15 .\" the use of the information contained herein. The author(s) may not
16 .\" have taken the same level of care in the production of this manual,
17 .\" which is licensed free of charge, as they might when working
20 .\" Formatted or processed versions of this manual, if unaccompanied by
21 .\" the source, must acknowledge the copyright and authors of this work.
23 .\" Japanese Version Copyright (c) 1997-2000 Kazuyuki Tanisako and NAKANO Takeo
24 .\" all rights reserved.
25 .\" Translated 1997-05-17, Kazuyuki Tanisako <tanisako@osa.dec-j.co.jp>
26 .\" Modified 1997-05-27, Kazuyuki Tanisako <tanisako@osa.dec-j.co.jp>
27 .\" Modified 1998-02-04, Kazuyuki Tanisako <tanisako@osa.dec-j.co.jp>
28 .\" Updated and Modified 2000-10-12, NAKANO Takeo <nakano@apm.seikei.ac.jp>
29 .\" Updated 2006-04-14, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>, LDP v2.29
30 .\" Updated 2006-07-26, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>, LDP v2.36
32 .\"WORD: temporary file テンポラリファイル
33 .\"WORD: filename ファイル名
35 .\"WORD: directory ディレクトリ
36 .\"WORD: environment variable 環境変数
39 .\"WORD: pointer ポインター
41 .TH TEMPNAM 3 2008-08-06 "" "Linux Programmer's Manual"
44 .\"O tempnam \- create a name for a temporary file
45 tempnam \- テンポラリファイルの名前を作成する
51 .BI "char *tempnam(const char *" dir ", const char *" pfx );
55 .\"O Feature Test Macro Requirements for glibc (see
56 .\"O .BR feature_test_macros (7)):
58 .RB ( feature_test_macros (7)
63 _BSD_SOURCE || _SVID_SOURCE
68 .\"O function returns a pointer to a string that is a valid filename,
69 .\"O and such that a file with this name did not exist when
72 .\"O The filename suffix of the pathname generated will start with
76 .\"O is a non-NULL string of at most five bytes.
77 .\"O The directory prefix part of the pathname generated is required to
78 .\"O be "appropriate" (often that at least implies writable).
80 関数はファイル名として正しい文字列へのポインターを返す。
83 がチェックした時点においては存在しない (しなかった)。
85 が NULL でない 5 バイト以内の文字列であれば、
89 生成されるディレクトリの部分は、「適切」でなければならない
90 (大抵の場合、「適切」であるためにはまず少なくとも
93 .\"O Attempts to find an appropriate directory go through the following
95 適切なディレクトリの探索は、以下の手順にしたがって行われる。
98 .\"O In case the environment variable
101 .\"O contains the name of an appropriate directory, that is used.
105 その内容が適切なディレクトリの名前なら、それを用いる。
108 .\"O Otherwise, if the
110 .\"O argument is non-NULL and appropriate, it is used.
113 引き数が NULL でない文字列でかつ適切なら、それを用いる。
120 .\"O is used when appropriate.
128 .\"O Finally an implementation-defined directory may be used.
129 最後に実装で定義されたディレクトリが用いられることになる。
131 .\"O The string returned by
133 .\"O is allocated using
135 .\"O and hence should be freed by
143 .\"O .SH "RETURN VALUE"
147 .\"O function returns a pointer to a unique temporary
148 .\"O filename, or NULL if a unique name cannot be generated.
150 関数は他と重ならないテンポラリファイル名へのポインタを返す。
151 他と重ならない名前が生成できなければ NULL を返す。
156 .\"O Allocation of storage failed.
158 .\"O .SH "CONFORMING TO"
160 SVr4, 4.3BSD, POSIX.1-2001.
161 .\"O POSIX.1-2008 marks
171 .\"O generates names that are difficult to guess,
172 .\"O it is nevertheless possible that between the time that
174 .\"O returns a pathname, and the time that the program opens it,
175 .\"O another program might create that pathname using
177 .\"O or create it as a symbolic link.
178 .\"O This can lead to security holes.
179 .\"O To avoid such possibilities, use the
182 .\"O flag to open the pathname.
183 .\"O Or better yet, use
186 .\"O .BR tmpfile (3).
188 は推測が難しい名前を生成するが、それにもかかわらず、
190 がパス名を返してから、プログラムがそのファイルをオープンする
191 までの間に、別のプログラムが同じパス名で、ファイルを
193 で作成したり、シンボリックリンクを作成したりする可能性がある。
194 これはセキュリティホールにつながる可能性がある。
199 フラグを使ってパス名をオープンすればよい。
206 .\"O SUSv2 does not mention the use of
208 .\"O glibc will use it only
209 .\"O when the program is not set-user-ID.
210 .\"O On SVr4, the directory used under \fBd)\fP is
212 .\"O (and this is what glibc does).
216 glibc は、プログラムが set-user-ID されていない場合に限ってこれを用いる。
217 SVr4 では \fBd)\fP で使用されるディレクトリを
219 と定めている (glibc もこの通りである)。
221 .\"O Because it dynamically allocates memory used to return the pathname,
223 .\"O is reentrant, and thus thread safe, unlike
225 パス名を返すのに使用するメモリを動的に確保するので、
229 はリエントラントであり、スレッドセーフである。
233 .\"O function generates a different string each time it is called,
239 .\"O If it is called more than
242 .\"O the behavior is implementation defined.
246 回まで、呼び出される度に異なる文字列を作成する
253 回以上呼び出された場合、動作は実装依存である。
256 .\"O uses at most the first five bytes from
263 .\"O The glibc implementation of
265 .\"O will fail with the error
267 .\"O upon failure to find a unique name.
268 他と重ならない名前が見つけられなかった場合、glibc の
275 .\"O The precise meaning of "appropriate" is undefined;
276 .\"O it is unspecified how accessibility of a directory is determined.
277 「適切」という言葉の正確な意味は定義されていない。
278 ディレクトリに対してどの程度のアクセス権限が必要なのかは指定されていない。
280 .\"O Never use this function.
286 決してこの関数を使ってはならない。代わりに