.\" Copyright (C) 1993 David Metcalfe (david@prism.demon.co.uk) .\" .\" 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. .\" .\" References consulted: .\" Linux libc source code .\" Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991) .\" 386BSD man pages .\" Modified Sat Jul 24 18:48:06 1993 by Rik Faith (faith@cs.unc.edu) .\" Modified Fri Jun 23 01:26:34 1995 by Andries Brouwer (aeb@cwi.nl) .\" (prompted by Scott Burkett ) .\" Modified Sun Mar 28 23:44:38 1999 by Andries Brouwer (aeb@cwi.nl) .\" .\" Japanese Version Copyright (c) 1997 Kazuyuki Tanisako .\" all rights reserved. .\" Translated Sat Apr 10 02:12:40 JST 1999 .\" by Kazuyuki Tanisako .\" .\"WORD: temporary file テンポラリファイル .\"WORD: filename ファイル名 .\"WORD: pointer ポインター .\"WORD: function 関数 .\" .TH MKTEMP 3 2010-09-20 "GNU" "Linux Programmer's Manual" .\"O .SH NAME .SH 名前 .\"O mktemp \- make a unique temporary filename mktemp \- 他と重ならないテンポラリファイル名を作成する .\"O .SH SYNOPSIS .SH 書式 .nf .B #include .sp .BI "char *mktemp(char *" template ); .fi .sp .in -4n .\"O Feature Test Macro Requirements for glibc (see .\"O .BR feature_test_macros (7)): glibc 向けの機能検査マクロの要件 .RB ( feature_test_macros (7) 参照): .in .sp .BR mktemp (): .ad l .PD 0 .RS 4 .TP 4 .\"O Since glibc 2.12: glibc 2.12 以降: _BSD_SOURCE || _SVID_SOURCE || (_XOPEN_SOURCE\ >=\ 500 || _XOPEN_SOURCE\ &&\ _XOPEN_SOURCE_EXTENDED) && !(_POSIX_C_SOURCE\ >=\ 200112L || _XOPEN_SOURCE\ >=\ 600) .TP .\"O Before glibc 2.12: glibc 2.12 より前: _BSD_SOURCE || _SVID_SOURCE || _XOPEN_SOURCE\ >=\ 500 || _XOPEN_SOURCE\ &&\ _XOPEN_SOURCE_EXTENDED .RE .PD .ad b \"O .SH DESCRIPTION .SH 説明 .\"O The .\"O .BR mktemp () .\"O function generates a unique temporary filename .\"O from \fItemplate\fP. .\"O The last six characters of \fItemplate\fP must .\"O be XXXXXX and these are replaced with a string that makes the .\"O filename unique. .\"O Since it will be modified, .\"O .I template .\"O must not be a string constant, but should be declared as a character array. 関数 .BR mktemp () は引数 \fItemplate\fP から他と重ならない テンポラリファイル名を作成する。引数 \fItemplate\fP で指示する文字配列 の後6文字は XXXXXX である必要がある。この部分がファイル名を他と 重ならないにするような文字で置き換えられる。 .I template は書き換えられるため、文字列定数ではなく文字配列として宣言するように しなければならない。 .\"O .SH "RETURN VALUE" .SH 返り値 .\"O The .\"O .BR mktemp () .\"O function always returns \fItemplate\fP. .\"O If a unique name was created, the last six bytes of \fItemplate\fP will .\"O have been modified in such a way that the resulting name is unique .\"O (i.e., does not exist already) .\"O If a unique name could not be created, .\"O \fItemplate\fP is made an empty string. 関数 .BR mktemp () は常に \fItemplate\fP を戻す。 一意な名前が作成された場合、 \fItemplate\fP の最後の 6 バイトに 他と重ならない名前 (それまでに出ていない名前) になるような値が格納される。 一意な名前が作成できなかった場合には、 \fItemplate\fP には空文字列がセットされる。 .\"O .SH ERRORS .SH エラー .TP .B EINVAL .\"O The last six characters of \fItemplate\fP were not XXXXXX. 引数 \fItemplate\fP で指示された文字列の後6文字が XXXXXX でない。 .\"O .SH "CONFORMING TO" .SH 準拠 4.3BSD, POSIX.1-2001. .\"O POSIX.1-2008 removes the specification of .\"O .BR mktemp (). POSIX.1-2008 では .BR mktemp () の仕様が削除されている。 .\"O .SH NOTES .SH 注意 .\"O The prototype is in .\"O .I .\"O for libc4, libc5, glibc1; glibc2 follows the Single UNIX Specification .\"O and has the prototype in .\"O .IR . libc4, libc5, glibc1 でのプロトタイプ宣言は .I に含まれる; glibc2 では Single UNIX Specification に従って .I に含まれている。 .\"O .SH BUGS .SH バグ .\"O Never use .\"O .BR mktemp (). .\"O Some implementations follow 4.3BSD .\"O and replace XXXXXX by the current process ID and a single letter, .\"O so that at most 26 different names can be returned. .BR mktemp () を決して使わないこと。4.3BSD 系の実装や XXXXXX を プロセス ID と1文字により置き換える方式ではせいぜい26の名前を返す ことができるにすぎない。 .\"O Since on the one hand the names are easy to guess, and on the other .\"O hand there is a race between testing whether the name exists and .\"O opening the file, every use of .\"O .BR mktemp () .\"O is a security risk. .\"O The race is avoided by .\"O .BR mkstemp (3). この名前は簡単に推測できることや、その名前がすでに存在しているかどうか テストして、そのファイルをオープンする間に競合がある事から、 .BR mktemp () を使うのは毎回セキュリティリスクをおかすことになる。 この競合は .BR mkstemp (3) を使うことで避けられる。 .\"O .SH "SEE ALSO" .SH 関連項目 .BR mkstemp (3), .BR tempnam (3), .BR tmpfile (3), .BR tmpnam (3)