File-Temp-0.12 >
0.22
との差分
File::Temp 0.22 と 0.12 の差分
1 | 1 | |
2 | 2 | =encoding euc-jp |
3 | 3 | |
4 | 4 | =head1 NAME |
5 | 5 | |
6 | 6 | =begin original |
7 | 7 | |
8 | 8 | File::Temp - return name and handle of a temporary file safely |
9 | 9 | |
10 | 10 | =end original |
11 | 11 | |
12 | File::Temp - | |
12 | File::Temp - テンポラリファイルの名前とハンドルを安全に返す | |
13 | 13 | |
14 | 14 | =begin __INTERNALS |
15 | 15 | |
16 | 16 | =head1 PORTABILITY |
17 | 17 | |
18 | 18 | (ポータビリティ) |
19 | 19 | |
20 | 20 | =begin original |
21 | 21 | |
22 | This | |
22 | This module is designed to be portable across operating systems | |
23 | ||
23 | and it currently supports Unix, VMS, DOS, OS/2 and Windows. When | |
24 | ||
24 | porting to a new OS there are generally three main issues | |
25 | a | |
25 | that have to be solved: | |
26 | 26 | |
27 | 27 | =end original |
28 | 28 | |
29 | この | |
29 | このモジュールはオペレーティングシステムをまたいで移植できるように設計されており、 | |
30 | ||
30 | 現在、Unix、VMS、DOS、OS/2、Windows をサポートしています。 | |
31 | ||
31 | 新しいOSに移植するときには、一般的に、3つの、解決されなければならない主要な問題があります: | |
32 | あなたがこのモジュールを新しいプラットフォームに | |
33 | 移植しようとしているのでないなら、SYNOPSIS 節まで読み飛ばしてください。 | |
34 | 32 | |
35 | =begin original | |
36 | ||
37 | This module is designed to be portable across operating systems and it | |
38 | currently supports Unix, VMS, DOS, OS/2, Windows and Mac OS | |
39 | (Classic). When porting to a new OS there are generally three main | |
40 | issues that have to be solved: | |
41 | ||
42 | =end original | |
43 | ||
44 | このモジュールはオペレーティングシステムをまたいで移植できるように | |
45 | 設計されており、 | |
46 | 現在、Unix, VMS, DOS, OS/2, Windows, Mac OS (Classic) に対応しています。 | |
47 | 新しい OS に移植するときには、一般的に、三つの解決されなければならない | |
48 | 主要な問題があります: | |
49 | ||
50 | 33 | =over 4 |
51 | 34 | |
52 | 35 | =item * |
53 | 36 | |
54 | 37 | =begin original |
55 | 38 | |
56 | 39 | Can the OS unlink an open file? If it can not then the |
57 | 40 | C<_can_unlink_opened_file> method should be modified. |
58 | 41 | |
59 | 42 | =end original |
60 | 43 | |
61 | その | |
44 | そのOSは、開いているファイルを削除できますか? | |
62 | もしできなければ、C<_can_unlink_opend_file> | |
45 | もしできなければ、C<_can_unlink_opend_file>メソッドは修正されるべきです。 | |
63 | 46 | |
64 | 47 | =item * |
65 | 48 | |
66 | 49 | =begin original |
67 | 50 | |
68 | 51 | Are the return values from C<stat> reliable? By default all the |
69 | 52 | return values from C<stat> are compared when unlinking a temporary |
70 | 53 | file using the filename and the handle. Operating systems other than |
71 | 54 | unix do not always have valid entries in all fields. If C<unlink0> fails |
72 | 55 | then the C<stat> comparison should be modified accordingly. |
73 | 56 | |
74 | 57 | =end original |
75 | 58 | |
76 | C<stat> | |
59 | C<stat>から返される値は信頼出来ますか? デフォルトでは、 | |
77 | ||
60 | C<stat>からの返り値の全てが、ファイル名とハンドルを使う一時ファイルを削除するときに、比較されます。 | |
78 | 一時ファイルを削除するときに比較されます。 | |
79 | 61 | unix 以外のオペレーティングシステムでは、全てのフィールドについて、 |
80 | 62 | 妥当な項目があるとは限りません。 |
81 | C<unlink0> が失敗すると、C<stat> の比較はそれに合わせて修正されるべきです。 | |
63 | もし、C<unlink0> が失敗すると、C<stat> の比較は、それに合わせて、修正されるべきです。 | |
82 | 64 | |
83 | 65 | =item * |
84 | 66 | |
85 | 67 | =begin original |
86 | 68 | |
87 | 69 | Security. Systems that can not support a test for the sticky bit |
88 | 70 | on a directory can not use the MEDIUM and HIGH security tests. |
89 | 71 | The C<_can_do_level> method should be modified accordingly. |
90 | 72 | |
91 | 73 | =end original |
92 | 74 | |
93 | セキュリティ。 | |
75 | セキュリティ。ディレクトリのスティッキービットのテストをサポートしないシステム | |
94 | ||
76 | は、中間と、高度の、セキュリティテストを使えません。 | |
95 | ||
77 | C<_can_do_level>メソッドはそれに応じて、修正されるべきです。 | |
96 | C<_can_do_level> メソッドはそれに応じて修正されるべきです。 | |
97 | 78 | |
98 | 79 | =back |
99 | 80 | |
100 | 81 | =end __INTERNALS |
101 | 82 | |
102 | 83 | =head1 SYNOPSIS |
103 | 84 | |
104 | use File::Temp qw/ tempfile tempdir /; | |
85 | use File::Temp qw/ tempfile tempdir /; | |
105 | 86 | |
106 | $ | |
87 | $dir = tempdir( CLEANUP => 1 ); | |
107 | ($fh, $filename) = tempfile(); | |
88 | ($fh, $filename) = tempfile( DIR => $dir ); | |
108 | 89 | |
109 | 90 | ($fh, $filename) = tempfile( $template, DIR => $dir); |
110 | 91 | ($fh, $filename) = tempfile( $template, SUFFIX => '.dat'); |
111 | ($fh, $filename) = tempfile( $template, TMPDIR => 1 ); | |
112 | 92 | |
113 | | |
93 | $fh = tempfile(); | |
114 | 94 | |
115 | $dir = tempdir( CLEANUP => 1 ); | |
116 | ($fh, $filename) = tempfile( DIR => $dir ); | |
117 | ||
118 | 95 | =begin original |
119 | 96 | |
120 | Object interface: | |
121 | ||
122 | =end original | |
123 | ||
124 | オブジェクトインターフェース: | |
125 | ||
126 | require File::Temp; | |
127 | use File::Temp (); | |
128 | use File::Temp qw/ :seekable /; | |
129 | ||
130 | $fh = File::Temp->new(); | |
131 | $fname = $fh->filename; | |
132 | ||
133 | $fh = File::Temp->new(TEMPLATE => $template); | |
134 | $fname = $fh->filename; | |
135 | ||
136 | $tmp = File::Temp->new( UNLINK => 0, SUFFIX => '.dat' ); | |
137 | print $tmp "Some data\n"; | |
138 | print "Filename is $tmp\n"; | |
139 | $tmp->seek( 0, SEEK_END ); | |
140 | ||
141 | =begin original | |
142 | ||
143 | The following interfaces are provided for compatibility with | |
144 | existing APIs. They should not be used in new code. | |
145 | ||
146 | =end original | |
147 | ||
148 | 以下のインターフェースは既存の API との互換性のために提供されています。 | |
149 | これらは新しいコードでは使うべきではありません。 | |
150 | ||
151 | =begin original | |
152 | ||
153 | 97 | MkTemp family: |
154 | 98 | |
155 | 99 | =end original |
156 | 100 | |
157 | 101 | MkTemp 系: |
158 | 102 | |
159 | 103 | use File::Temp qw/ :mktemp /; |
160 | 104 | |
161 | 105 | ($fh, $file) = mkstemp( "tmpfileXXXXX" ); |
162 | 106 | ($fh, $file) = mkstemps( "tmpfileXXXXXX", $suffix); |
163 | 107 | |
164 | 108 | $tmpdir = mkdtemp( $template ); |
165 | 109 | |
166 | 110 | $unopened_file = mktemp( $template ); |
167 | 111 | |
168 | 112 | =begin original |
169 | 113 | |
170 | 114 | POSIX functions: |
171 | 115 | |
172 | 116 | =end original |
173 | 117 | |
174 | 118 | POSIX 関数: |
175 | 119 | |
176 | 120 | use File::Temp qw/ :POSIX /; |
177 | 121 | |
178 | 122 | $file = tmpnam(); |
179 | 123 | $fh = tmpfile(); |
180 | 124 | |
181 | 125 | ($fh, $file) = tmpnam(); |
126 | ($fh, $file) = tmpfile(); | |
182 | 127 | |
183 | 128 | =begin original |
184 | 129 | |
185 | 130 | Compatibility functions: |
186 | 131 | |
187 | 132 | =end original |
188 | 133 | |
189 | 134 | 互換関数: |
190 | 135 | |
191 | 136 | $unopened_file = File::Temp::tempnam( $dir, $pfx ); |
192 | 137 | |
138 | =begin later | |
139 | ||
140 | Objects (NOT YET IMPLEMENTED): | |
141 | ||
142 | require File::Temp; | |
143 | ||
144 | $fh = new File::Temp($template); | |
145 | $fname = $fh->filename; | |
146 | ||
147 | =end later | |
148 | ||
193 | 149 | =head1 DESCRIPTION |
194 | 150 | |
195 | 151 | =begin original |
196 | 152 | |
197 | C<File::Temp> can be used to create and open temporary files in a safe | |
153 | C<File::Temp> can be used to create and open temporary files in a safe way. | |
198 | ||
154 | The tempfile() function can be used to return the name and the open | |
199 | i | |
155 | filehandle of a temporary file. The tempdir() function can | |
200 | be used to re | |
156 | be used to create a temporary directory. | |
201 | file. The tempdir() function can be used to create a temporary | |
202 | directory. | |
203 | 157 | |
204 | 158 | =end original |
205 | 159 | |
206 | 160 | C<File::Temp> は、安全な方法で、一時ファイルを作成し、開くのに使えます。 |
207 | 関数 | |
161 | tempfile() 関数は、一時ファイルの名前と、開いたファイルハンドルを返すのに | |
208 | ||
162 | 使われます。 | |
209 | 開いたファイルハンドルを返すのに使われます。 | |
210 | 163 | tempdir() 関数は、一時ディレクトリを作成するのに使われます。 |
211 | 164 | |
212 | 165 | =begin original |
213 | 166 | |
214 | 167 | The security aspect of temporary file creation is emphasized such that |
215 | 168 | a filehandle and filename are returned together. This helps guarantee |
216 | 169 | that a race condition can not occur where the temporary file is |
217 | 170 | created by another process between checking for the existence of the |
218 | 171 | file and its opening. Additional security levels are provided to |
219 | 172 | check, for example, that the sticky bit is set on world writable |
220 | 173 | directories. See L<"safe_level"> for more information. |
221 | 174 | |
222 | 175 | =end original |
223 | 176 | |
224 | 177 | 一時ファイルを作成することのセキュリティの側面が、ファイルハンドルと |
225 | 178 | ファイル名が一緒に返されるということで、強調されます。 |
226 | 179 | これが、ファイルが存在するかをチェックし、ファイルを開いている間に |
227 | 180 | 別のプロセスによってテンポラリファイルが作られる、という |
228 | 181 | 競合条件が起こらないことを保証するのを助けています。 |
229 | 182 | 追加のセキュリティレベルが提供されています; |
230 | 183 | 例えば、スティッキービットが全体書き込み可能なディレクトリに |
231 | 184 | セットされているかのチェックです。 |
232 | 185 | 詳細は L<"safe_level"> を参照してください。 |
233 | 186 | |
234 | 187 | =begin original |
235 | 188 | |
236 | 189 | For compatibility with popular C library functions, Perl implementations of |
237 | 190 | the mkstemp() family of functions are provided. These are, mkstemp(), |
238 | 191 | mkstemps(), mkdtemp() and mktemp(). |
239 | 192 | |
240 | 193 | =end original |
241 | 194 | |
242 | 195 | 一般的な C ライブラリ関数との互換性のために、 |
243 | 196 | mkstemp() 関数の仲間の Perl 実装が提供されています。 |
244 | 197 | mkstemp(), mkstemps(), mkdtemp(), mktemp() があります。 |
245 | 198 | |
246 | 199 | =begin original |
247 | 200 | |
248 | 201 | Additionally, implementations of the standard L<POSIX|POSIX> |
249 | 202 | tmpnam() and tmpfile() functions are provided if required. |
250 | 203 | |
251 | 204 | =end original |
252 | 205 | |
253 | 206 | さらに、もし必要なら、標準の L<POSIX|POSIX> の実装である tmpnam() と |
254 | 207 | tmpfile() が提供されます。 |
255 | 208 | |
256 | 209 | =begin original |
257 | 210 | |
258 | 211 | Implementations of mktemp(), tmpnam(), and tempnam() are provided, |
259 | 212 | but should be used with caution since they return only a filename |
260 | 213 | that was valid when function was called, so cannot guarantee |
261 | 214 | that the file will not exist by the time the caller opens the filename. |
262 | 215 | |
263 | 216 | =end original |
264 | 217 | |
265 | 218 | mktemp(), tmpanam(), tempnam() の実装は提供されていますが、 |
266 | 219 | 注意して使われるべきです; |
267 | 220 | なぜなら、関数が呼ばれると、妥当なファイル名だけを返すので、 |
268 | 221 | 呼び出し側がファイルを開く時にそのファイルが存在していないことを |
269 | 222 | 保証できないからです。 |
270 | 223 | |
271 | =begin original | |
272 | ||
273 | Filehandles returned by these functions support the seekable methods. | |
274 | ||
275 | =end original | |
276 | ||
277 | これらの関数で返されるファイルハンドルは seekable メソッドに対応しています。 | |
278 | ||
279 | =cut | |
280 | ||
281 | =head1 OBJECT-ORIENTED INTERFACE | |
282 | ||
283 | (オブジェクト指向インターフェース) | |
284 | ||
285 | =begin original | |
286 | ||
287 | This is the primary interface for interacting with | |
288 | C<File::Temp>. Using the OO interface a temporary file can be created | |
289 | when the object is constructed and the file can be removed when the | |
290 | object is no longer required. | |
291 | ||
292 | =end original | |
293 | ||
294 | これは C<File::Temp> と相互作用するための主インターフェースです。 | |
295 | OO インターフェースを使うことで、オブジェクトが作成されたときに一時ファイルが | |
296 | 作成され、オブジェクトが不要になったときにファイルが削除されます。 | |
297 | ||
298 | =begin original | |
299 | ||
300 | Note that there is no method to obtain the filehandle from the | |
301 | C<File::Temp> object. The object itself acts as a filehandle. Also, | |
302 | the object is configured such that it stringifies to the name of the | |
303 | temporary file, and can be compared to a filename directly. The object | |
304 | isa C<IO::Handle> and isa C<IO::Seekable> so all those methods are | |
305 | available. | |
306 | ||
307 | =end original | |
308 | ||
309 | C<File::Temp> オブジェクトからファイルハンドルを得るメソッドはないことに | |
310 | 注意してください。 | |
311 | オブジェクト自身がファイルハンドルとして振る舞います。 | |
312 | また、オブジェクトは文字列化されると一時ファイル名になるように | |
313 | 設定されているので、ファイル名と直接比較できます。 | |
314 | オブジェクトは C<IO::Handle> であり C<IO::Seekable> であるので | |
315 | これらの全てのメソッドが利用可能です。 | |
316 | ||
317 | =over 4 | |
318 | ||
319 | =item B<new> | |
320 | ||
321 | =begin original | |
322 | ||
323 | Create a temporary file object. | |
324 | ||
325 | =end original | |
326 | ||
327 | 一時ファイルオブジェクトを作成します。 | |
328 | ||
329 | my $tmp = File::Temp->new(); | |
330 | ||
331 | =begin original | |
332 | ||
333 | by default the object is constructed as if C<tempfile> | |
334 | was called without options, but with the additional behaviour | |
335 | that the temporary file is removed by the object destructor | |
336 | if UNLINK is set to true (the default). | |
337 | ||
338 | =end original | |
339 | ||
340 | デフォルトではオプションなしで C<tempfile> が呼び出されたかのようにして | |
341 | オブジェクトが作成されますが、追加の振る舞いとして、UNLINK が | |
342 | 真 (これがデフォルトです) の場合、オブジェクトのデストラクタによって | |
343 | 一時ファイルは削除されます。 | |
344 | ||
345 | =begin original | |
346 | ||
347 | Supported arguments are the same as for C<tempfile>: UNLINK | |
348 | (defaulting to true), DIR, EXLOCK and SUFFIX. Additionally, the filename | |
349 | template is specified using the TEMPLATE option. The OPEN option | |
350 | is not supported (the file is always opened). | |
351 | ||
352 | =end original | |
353 | ||
354 | 対応している引数は C<tempfile> と同じです: UNLINK | |
355 | (デフォルトは真), DIR, EXLOCK, SUFFIX。 | |
356 | さらに、ファイル名テンプレートは TEMPLATE オプションを使って指定します。 | |
357 | OPEN オプションは対応していません (ファイルは常に開かれます)。 | |
358 | ||
359 | $tmp = File::Temp->new( TEMPLATE => 'tempXXXXX', | |
360 | DIR => 'mydir', | |
361 | SUFFIX => '.dat'); | |
362 | ||
363 | =begin original | |
364 | ||
365 | Arguments are case insensitive. | |
366 | ||
367 | =end original | |
368 | ||
369 | 引数は大文字小文字を無視します。 | |
370 | ||
371 | =begin original | |
372 | ||
373 | Can call croak() if an error occurs. | |
374 | ||
375 | =end original | |
376 | ||
377 | エラーが起きると croak() を呼び出すことがあります。 | |
378 | ||
379 | =cut | |
380 | ||
381 | =item B<newdir> | |
382 | ||
383 | =begin original | |
384 | ||
385 | Create a temporary directory using an object oriented interface. | |
386 | ||
387 | =end original | |
388 | ||
389 | オブジェクト指向インターフェースを使って一時ディレクトリを作成します。 | |
390 | ||
391 | $dir = File::Temp->newdir(); | |
392 | ||
393 | =begin original | |
394 | ||
395 | By default the directory is deleted when the object goes out of scope. | |
396 | ||
397 | =end original | |
398 | ||
399 | デフォルトでは、オブジェクトがスコープ外になるとディレクトリは削除されます。 | |
400 | ||
401 | =begin original | |
402 | ||
403 | Supports the same options as the C<tempdir> function. Note that directories | |
404 | created with this method default to CLEANUP => 1. | |
405 | ||
406 | =end original | |
407 | ||
408 | C<tempdir> 関数と同じオプションに対応しています。 | |
409 | このメソッドで作られたディレクトリはデフォルトで CLEANUP => 1 になることに | |
410 | 注意してください。 | |
411 | ||
412 | $dir = File::Temp->newdir( $template, %options ); | |
413 | ||
414 | =cut | |
415 | ||
416 | =item B<filename> | |
417 | ||
418 | =begin original | |
419 | ||
420 | Return the name of the temporary file associated with this object | |
421 | (if the object was created using the "new" constructor). | |
422 | ||
423 | =end original | |
424 | ||
425 | (このオブジェクトが "new" コンストラクタを使って作成されていれば) | |
426 | このオブジェクトに関連付けられた一時ファイル名を返します。 | |
427 | ||
428 | $filename = $tmp->filename; | |
429 | ||
430 | =begin original | |
431 | ||
432 | This method is called automatically when the object is used as | |
433 | a string. | |
434 | ||
435 | =end original | |
436 | ||
437 | このメソッドは、このオブジェクトが文字列として使われると自動的に | |
438 | 呼び出されます。 | |
439 | ||
440 | =cut | |
441 | ||
442 | =item B<dirname> | |
443 | ||
444 | =begin original | |
445 | ||
446 | Return the name of the temporary directory associated with this | |
447 | object (if the object was created using the "newdir" constructor). | |
448 | ||
449 | =end original | |
450 | ||
451 | (このオブジェクトが "newdir" コンストラクタを使って作成されていれば) | |
452 | このオブジェクトに関連付けられた一時ディレクトリ名を返します。 | |
453 | ||
454 | $dirname = $tmpdir->dirname; | |
455 | ||
456 | =begin original | |
457 | ||
458 | This method is called automatically when the object is used in string context. | |
459 | ||
460 | =end original | |
461 | ||
462 | このメソッドは、このオブジェクトが文字列コンテキストで使われると自動的に | |
463 | 呼び出されます。 | |
464 | ||
465 | =item B<unlink_on_destroy> | |
466 | ||
467 | =begin original | |
468 | ||
469 | Control whether the file is unlinked when the object goes out of scope. | |
470 | The file is removed if this value is true and $KEEP_ALL is not. | |
471 | ||
472 | =end original | |
473 | ||
474 | オブジェクトがスコープ外になったときにファイルを削除(unlink)するかどうかを | |
475 | 制御します。 | |
476 | この値が真で、$KEEP_ALL が真でなければ、ファイルは削除されます。 | |
477 | ||
478 | $fh->unlink_on_destroy( 1 ); | |
479 | ||
480 | =begin original | |
481 | ||
482 | Default is for the file to be removed. | |
483 | ||
484 | =end original | |
485 | ||
486 | デフォルトではファイルは削除されます。 | |
487 | ||
488 | =cut | |
489 | ||
490 | =item B<DESTROY> | |
491 | ||
492 | =begin original | |
493 | ||
494 | When the object goes out of scope, the destructor is called. This | |
495 | destructor will attempt to unlink the file (using C<unlink1>) | |
496 | if the constructor was called with UNLINK set to 1 (the default state | |
497 | if UNLINK is not specified). | |
498 | ||
499 | =end original | |
500 | ||
501 | オブジェクトがスコープ外になったとき、デストラクタが呼び出されます。 | |
502 | このデストラクタは、UNLINK を 1 (UNLINK が指定されなかった場合のデフォルトは | |
503 | これです)に設定してコンストラクタが呼び出されていると、(C<unlink1> を使って) | |
504 | ファイルを削除しようとします。 | |
505 | ||
506 | =begin original | |
507 | ||
508 | No error is given if the unlink fails. | |
509 | ||
510 | =end original | |
511 | ||
512 | 削除に失敗してもエラーは発生しません。 | |
513 | ||
514 | =begin original | |
515 | ||
516 | If the object has been passed to a child process during a fork, the | |
517 | file will be deleted when the object goes out of scope in the parent. | |
518 | ||
519 | =end original | |
520 | ||
521 | フォークによってこのオブジェクトが子プロセスに渡されると、 | |
522 | 親でこのオブジェクトがスコープ外になったときにファイルは削除されます。 | |
523 | ||
524 | =begin original | |
525 | ||
526 | For a temporary directory object the directory will be removed | |
527 | unless the CLEANUP argument was used in the constructor (and set to | |
528 | false) or C<unlink_on_destroy> was modified after creation. | |
529 | ||
530 | =end original | |
531 | ||
532 | 一時ディレクトリオブジェクトについては、コンストラクタで | |
533 | CLEANUP 引数が使われ(そして偽に設定され)るか、 | |
534 | 作成後に C<unlink_on_destroy> が変更されない限り、 | |
535 | ディレクトリは削除されます。 | |
536 | ||
537 | =begin original | |
538 | ||
539 | If the global variable $KEEP_ALL is true, the file or directory | |
540 | will not be removed. | |
541 | ||
542 | =end original | |
543 | ||
544 | グローバル変数 $KEEP_ALL が真の場合、ファイルやディレクトリは削除されません。 | |
545 | ||
546 | =cut | |
547 | ||
548 | =back | |
549 | ||
550 | 224 | =head1 FUNCTIONS |
551 | 225 | |
552 | 226 | (関数) |
553 | 227 | |
554 | 228 | =begin original |
555 | 229 | |
556 | 230 | This section describes the recommended interface for generating |
557 | 231 | temporary files and directories. |
558 | 232 | |
559 | 233 | =end original |
560 | 234 | |
561 | 235 | この節では、一時ファイルと一時ディレクトリを生成するための、 |
562 | 236 | 推奨されるインターフェースについて説明します。 |
563 | 237 | |
564 | 238 | =over 4 |
565 | 239 | |
566 | 240 | =item B<tempfile> |
567 | 241 | |
568 | 242 | =begin original |
569 | 243 | |
570 | 244 | This is the basic function to generate temporary files. |
571 | 245 | The behaviour of the file can be changed using various options: |
572 | 246 | |
573 | 247 | =end original |
574 | 248 | |
575 | 249 | これは基本的な関数で、一時ファイルを生成します。 |
576 | 250 | ファイルの振る舞いは様々なオプションで変更できます: |
577 | 251 | |
578 | $fh = tempfile(); | |
579 | 252 | ($fh, $filename) = tempfile(); |
580 | 253 | |
581 | 254 | =begin original |
582 | 255 | |
583 | 256 | Create a temporary file in the directory specified for temporary |
584 | 257 | files, as specified by the tmpdir() function in L<File::Spec>. |
585 | 258 | |
586 | 259 | =end original |
587 | 260 | |
588 | 261 | L<File::Spec> の tmpdir() 関数で指定される |
589 | 262 | 一時ファイル用のディレクトリに、一時ファイルを作成します。 |
590 | 263 | |
591 | 264 | ($fh, $filename) = tempfile($template); |
592 | 265 | |
593 | 266 | =begin original |
594 | 267 | |
595 | 268 | Create a temporary file in the current directory using the supplied |
596 | 269 | template. Trailing `X' characters are replaced with random letters to |
597 | 270 | generate the filename. At least four `X' characters must be present |
598 | ||
271 | in the template. | |
599 | 272 | |
600 | 273 | =end original |
601 | 274 | |
602 | 275 | 現在のディレクトリに、提供されたテンプレートを使って、 |
603 | 276 | 一時ファイルを作成します。 |
604 | 277 | ファイル名を生成するときに、 |
605 | 278 | 末尾の文字 `X' はランダムな文字に置き換えられます。 |
606 | 少なくとも四つの `X' 文字がテンプレート | |
279 | 少なくとも四つの `X' 文字がテンプレートになければなりません。 | |
607 | 280 | |
608 | 281 | ($fh, $filename) = tempfile($template, SUFFIX => $suffix) |
609 | 282 | |
610 | 283 | =begin original |
611 | 284 | |
612 | 285 | Same as previously, except that a suffix is added to the template |
613 | 286 | after the `X' translation. Useful for ensuring that a temporary |
614 | 287 | filename has a particular extension when needed by other applications. |
615 | 288 | But see the WARNING at the end. |
616 | 289 | |
617 | 290 | =end original |
618 | 291 | |
619 | 292 | `X' の変換の後に接尾辞が加えられることを除いて、前のものと同じです。 |
620 | 293 | 他のアプリケーションで必要とされるときに、 |
621 | 294 | テンポラリファイルに特別の拡張子があるようにしたい場合に便利です。 |
622 | 295 | しかし、最後の警告を参照してください。 |
623 | 296 | |
624 | 297 | ($fh, $filename) = tempfile($template, DIR => $dir); |
625 | 298 | |
626 | 299 | =begin original |
627 | 300 | |
628 | 301 | Translates the template as before except that a directory name |
629 | 302 | is specified. |
630 | 303 | |
631 | 304 | =end original |
632 | 305 | |
633 | 306 | ディレクトリの名前が指定されているのを除いて、 |
634 | 307 | 前述のものと同様にテンプレートを変換します。 |
635 | 308 | |
636 | ($fh, $filename) = tempfile($template, TMPDIR => 1); | |
637 | ||
638 | =begin original | |
639 | ||
640 | Equivalent to specifying a DIR of "File::Spec->tmpdir", writing the file | |
641 | into the same temporary directory as would be used if no template was | |
642 | specified at all. | |
643 | ||
644 | =end original | |
645 | ||
646 | DIR に "File::Spec->tmpdir" を指定したのと等価で、 | |
647 | テンプレートが全く指定されなかった場合に使われる同じ一時ディレクトリに | |
648 | ファイルを書き込みます。 | |
649 | ||
650 | 309 | ($fh, $filename) = tempfile($template, UNLINK => 1); |
651 | 310 | |
652 | 311 | =begin original |
653 | 312 | |
654 | 313 | Return the filename and filehandle as before except that the file is |
655 | automatically removed when the program exits | |
314 | automatically removed when the program exits. Default is for the file | |
656 | ||
315 | to be removed if a file handle is requested and to be kept if the | |
657 | ||
316 | filename is requested. In a scalar context (where no filename is | |
658 | ||
317 | returned) the file is always deleted either on exit or when it is closed. | |
659 | either (depending on the operating system) on exit or when it is | |
660 | closed (unless $KEEP_ALL is true when the temp file is created). | |
661 | 318 | |
662 | 319 | =end original |
663 | 320 | |
664 | 前述のようにファイル名とファイルハンドルを返しますが、 | |
321 | 前述のようにファイル名とファイルハンドルを返しますが、 | |
665 | 322 | プログラムが終了したときに自動的に一時ファイルが削除されます。 |
666 | 323 | デフォルトでは、ファイルは、ファイルハンドルが要求されれば削除され、 |
667 | 324 | ファイル名が要求されれば保持されます。 |
668 | (ファイル名が返されない)スカラコンテキストでは、 | |
325 | (ファイル名が返されない)スカラコンテキストでは、終了時か、閉じられたときに、 | |
669 | ||
326 | ファイルはいつも削除されます。 | |
670 | 閉じられたときに、ファイルはいつも削除されます。 | |
671 | 327 | |
672 | 328 | =begin original |
673 | 329 | |
674 | Use the object-oriented interface if fine-grained control of when | |
675 | a file is removed is required. | |
676 | ||
677 | =end original | |
678 | ||
679 | いつファイルが削除されるかについての細かい制御が必要な場合は、 | |
680 | オブジェクト指向インターフェースを使ってください。 | |
681 | ||
682 | =begin original | |
683 | ||
684 | 330 | If the template is not specified, a template is always |
685 | 331 | automatically generated. This temporary file is placed in tmpdir() |
686 | (L<File::Spec>) unless a directory is specified explicitly with the | |
332 | (L<File::Spec>) unless a directory is specified explicitly with the | |
687 | 333 | DIR option. |
688 | 334 | |
689 | 335 | =end original |
690 | 336 | |
691 | 337 | テンプレートが指定されない場合、テンプレートは常に自動的に生成されます。 |
692 | 338 | この一時ファイルは、DIR オプションで明示的にディレクトリが指定されない限り、 |
693 | 339 | tmpdir()(L<File::Spec>) に置かれます。 |
694 | 340 | |
695 | $fh = tempfile( DIR => $dir ); | |
341 | $fh = tempfile( $template, DIR => $dir ); | |
696 | 342 | |
697 | 343 | =begin original |
698 | 344 | |
699 | If called in scalar context, only the filehandle is returned | |
345 | If called in scalar context, only the filehandle is returned | |
700 | file will automatically be deleted when closed | |
346 | and the file will automatically be deleted when closed (see | |
701 | th | |
347 | the description of tmpfile() elsewhere in this document). | |
702 | ||
348 | This is the preferred mode of operation, as if you only | |
703 | have a filehandle, you can never create a race condition | |
349 | have a filehandle, you can never create a race condition | |
704 | with the filename. On systems that can not unlink | |
350 | by fumbling with the filename. On systems that can not unlink | |
705 | not mark a file as temporary when it is opened | |
351 | an open file or can not mark a file as temporary when it is opened | |
706 | NT uses the C<O_TEMPORARY> flag) | |
352 | (for example, Windows NT uses the C<O_TEMPORARY> flag)) | |
707 | the program ends (equivalent | |
353 | the file is marked for deletion when the program ends (equivalent | |
708 | flag is ignored if present. | |
354 | to setting UNLINK to 1). The C<UNLINK> flag is ignored if present. | |
709 | 355 | |
710 | 356 | =end original |
711 | 357 | |
712 | 358 | スカラコンテキストで呼ばれると、ファイルハンドルが返され、 |
713 | 閉じられると | |
359 | 閉じられると(この文書の他の場所にある tmpfile() を参照してください)、 | |
714 | ||
360 | ファイルは自動的に削除されます。 | |
715 | 361 | ファイルハンドルだけを持つのなら、これは好ましい方法です; |
716 | 362 | ファイルネームを変更することで競合条件を作ることはありません。 |
717 | 363 | 開いているファイルを削除できない、あるいはファイルを開いていると |
718 | 364 | 一時的であるとしてファイルにマークをつけることのできないシステムでは |
719 | 365 | (たとえば、Windows NT は、C<O_TEMPORARY> フラグを使います)、 |
720 | 366 | ファイルは、プログラムの終了時に、削除用のマークがつけられます |
721 | 367 | (UNLINK を 1 に設定するのと同じ)。 |
722 | 368 | C<UNLINK> フラグは、あっても無視されます。 |
723 | 369 | |
724 | 370 | (undef, $filename) = tempfile($template, OPEN => 0); |
725 | 371 | |
726 | 372 | =begin original |
727 | 373 | |
728 | 374 | This will return the filename based on the template but |
729 | 375 | will not open this file. Cannot be used in conjunction with |
730 | UNLINK set to true. Default is to always open the file | |
376 | UNLINK set to true. Default is to always open the file | |
731 | 377 | to protect from possible race conditions. A warning is issued |
732 | 378 | if warnings are turned on. Consider using the tmpnam() |
733 | 379 | and mktemp() functions described elsewhere in this document |
734 | 380 | if opening the file is not required. |
735 | 381 | |
736 | 382 | =end original |
737 | 383 | |
738 | 384 | これはテンプレートを元にしたファイル名を返しますが、そのファイルを |
739 | 385 | 開きません。 |
740 | 386 | UNILINK を真に設定するのと同時には使えません。 |
741 | 387 | デフォルトでは常にファイルを開き、競合条件の可能性から保護します。 |
742 | 388 | 警告が有効になっている場合は、、警告が出力されます。 |
743 | 389 | ファイルを開くことを要求しないなら、この文書の他の場所で説明されている |
744 | 390 | tmpnam() と、mktemp() 関数を使うことを検討してください。 |
745 | 391 | |
746 | 392 | =begin original |
747 | 393 | |
748 | If the operating system supports it (for example BSD derived systems), the | |
749 | filehandle will be opened with O_EXLOCK (open with exclusive file lock). | |
750 | This can sometimes cause problems if the intention is to pass the filename | |
751 | to another system that expects to take an exclusive lock itself (such as | |
752 | DBD::SQLite) whilst ensuring that the tempfile is not reused. In this | |
753 | situation the "EXLOCK" option can be passed to tempfile. By default EXLOCK | |
754 | will be true (this retains compatibility with earlier releases). | |
755 | ||
756 | =end original | |
757 | ||
758 | (例えば BSD 派生のシステムのように)オペレーティングシステムが | |
759 | これに対応しているなら、 | |
760 | ファイルハンドルは O_EXLOCK (排他ファイルロックで開く) で開かれます。 | |
761 | これは、目的が、(DBD::SQLite のように) 自分自身で排他ロックを取って | |
762 | 一時ファイルが再利用されないようにすることを想定している別のシステムに | |
763 | パスを渡すことの場合、問題になることがあります。 | |
764 | この場合、"EXLOCK" オプションを tempfile に渡せます。 | |
765 | デフォルトでは EXLOCK は真です (これは以前のリリースとの互換性を維持します)。 | |
766 | ||
767 | ($fh, $filename) = tempfile($template, EXLOCK => 0); | |
768 | ||
769 | =begin original | |
770 | ||
771 | 394 | Options can be combined as required. |
772 | 395 | |
773 | 396 | =end original |
774 | 397 | |
775 | オプションは必要に応じて組み合わせることができます。 | |
398 | オプションは、必要に応じて、組み合わせることができます。 | |
776 | 399 | |
777 | =begin original | |
778 | ||
779 | Will croak() if there is an error. | |
780 | ||
781 | =end original | |
782 | ||
783 | エラーがあると croak() します。 | |
784 | ||
785 | =cut | |
786 | ||
787 | 400 | =item B<tempdir> |
788 | 401 | |
789 | 402 | =begin original |
790 | 403 | |
791 | This is the recommended interface for creation of temporary | |
404 | This is the recommended interface for creation of temporary directories. | |
792 | ||
405 | The behaviour of the function depends on the arguments: | |
793 | (that is, it won't be temporary; this behaviour can not be changed | |
794 | because of issues with backwards compatibility). To enable removal | |
795 | either use the CLEANUP option which will trigger removal on program | |
796 | exit, or consider using the "newdir" method in the object interface which | |
797 | will allow the directory to be cleaned up when the object goes out of | |
798 | scope. | |
799 | 406 | |
800 | 407 | =end original |
801 | 408 | |
802 | 409 | これは、一時ディレクトリを作成するための推奨されるインターフェースです。 |
803 | ||
410 | この関数の振舞は引数によります: | |
804 | (つまり、これは一時的ではありません; この振る舞いは過去互換性問題により | |
805 | 変更できません)。 | |
806 | 削除を有効にするには、 | |
807 | プログラム終了時に削除を行う CLEANUP オプションを使うか、 | |
808 | オブジェクトインターフェースで "newdir" メソッドを使うことを検討してください; | |
809 | これはオブジェクトがスコープ外になったときにディレクトリを | |
810 | 片付けることができます。 | |
811 | 411 | |
812 | =begin original | |
813 | ||
814 | The behaviour of the function depends on the arguments: | |
815 | ||
816 | =end original | |
817 | ||
818 | この関数の振る舞いは引数によります: | |
819 | ||
820 | 412 | $tempdir = tempdir(); |
821 | 413 | |
822 | 414 | =begin original |
823 | 415 | |
824 | 416 | Create a directory in tmpdir() (see L<File::Spec|File::Spec>). |
825 | 417 | |
826 | 418 | =end original |
827 | 419 | |
828 | 420 | tmpdir() でディレクトリを作成します |
829 | 421 | (L<File::Spec|File::Spec> を参照してください)。 |
830 | 422 | |
831 | 423 | $tempdir = tempdir( $template ); |
832 | 424 | |
833 | 425 | =begin original |
834 | 426 | |
835 | 427 | Create a directory from the supplied template. This template is |
836 | 428 | similar to that described for tempfile(). `X' characters at the end |
837 | 429 | of the template are replaced with random letters to construct the |
838 | 430 | directory name. At least four `X' characters must be in the template. |
839 | 431 | |
840 | 432 | =end original |
841 | 433 | |
842 | 434 | 提供されたテンプレートから、ディレクトリを作成します。 |
843 | 435 | このテンプレートは tempfile() で説明されたものと似ています。 |
844 | 436 | テンプレートの末尾の `X' 文字はランダムな文字に置き換えられ、 |
845 | 437 | ディレクトリ名を作ります。 |
846 | 438 | テンプレートには少なくとも四つ `X' 文字がなければいけません。 |
847 | 439 | |
848 | 440 | $tempdir = tempdir ( DIR => $dir ); |
849 | 441 | |
850 | 442 | =begin original |
851 | 443 | |
852 | 444 | Specifies the directory to use for the temporary directory. |
853 | 445 | The temporary directory name is derived from an internal template. |
854 | 446 | |
855 | 447 | =end original |
856 | 448 | |
857 | 449 | 一時ディレクトリに使うディレクトリを指定します。 |
858 | 450 | 一時ディレクトリ名は、内部のテンプレートから生成されます。 |
859 | 451 | |
860 | 452 | $tempdir = tempdir ( $template, DIR => $dir ); |
861 | 453 | |
862 | 454 | =begin original |
863 | 455 | |
864 | 456 | Prepend the supplied directory name to the template. The template |
865 | 457 | should not include parent directory specifications itself. Any parent |
866 | 458 | directory specifications are removed from the template before |
867 | 459 | prepending the supplied directory. |
868 | 460 | |
869 | 461 | =end original |
870 | 462 | |
871 | 463 | 指定されたディレクトリ名をテンプレートに前置します。 |
872 | 464 | テンプレートは、親ディレクトリ指定そのものを含むべきではありません。 |
873 | 465 | 指定されたディレクトリを前置する前に、親ディレクトリ指定は |
874 | 466 | テンプレートから削除されます。 |
875 | 467 | |
876 | 468 | $tempdir = tempdir ( $template, TMPDIR => 1 ); |
877 | 469 | |
878 | 470 | =begin original |
879 | 471 | |
880 | Using the supplied template, creat | |
472 | Using the supplied template, creat the temporary directory in | |
881 | 473 | a standard location for temporary files. Equivalent to doing |
882 | 474 | |
883 | 475 | =end original |
884 | 476 | |
885 | 477 | 指定された template を使うと、一時ファイルのための標準の場所に、 |
886 | 478 | 一時ディレクトリを作ります。 |
887 | 479 | 次のようにするのと同じですが: |
888 | 480 | |
889 | 481 | $tempdir = tempdir ( $template, DIR => File::Spec->tmpdir); |
890 | 482 | |
891 | 483 | =begin original |
892 | 484 | |
893 | 485 | but shorter. Parent directory specifications are stripped from the |
894 | 486 | template itself. The C<TMPDIR> option is ignored if C<DIR> is set |
895 | 487 | explicitly. Additionally, C<TMPDIR> is implied if neither a template |
896 | 488 | nor a directory are supplied. |
897 | 489 | |
898 | 490 | =end original |
899 | 491 | |
900 | ||
492 | 上の方が、短くなります。 | |
901 | 493 | 親ディレクトリ指定はテンプレート自身から除去されます。 |
902 | 494 | C<DIR> が明示的に設定されていれば C<TMPDIR> オプションは無視されます。 |
903 | 495 | 加えて、テンプレートもディレクトリも指定されていなければ、 |
904 | 496 | C<TMPDIR> が仮定されます。 |
905 | 497 | |
906 | 498 | $tempdir = tempdir( $template, CLEANUP => 1); |
907 | 499 | |
908 | 500 | =begin original |
909 | 501 | |
910 | Create a temporary directory using the supplied template, but | |
502 | Create a temporary directory using the supplied template, but | |
911 | 503 | attempt to remove it (and all files inside it) when the program |
912 | 504 | exits. Note that an attempt will be made to remove all files from |
913 | 505 | the directory even if they were not created by this module (otherwise |
914 | 506 | why ask to clean it up?). The directory removal is made with |
915 | 507 | the rmtree() function from the L<File::Path|File::Path> module. |
916 | 508 | Of course, if the template is not specified, the temporary directory |
917 | 509 | will be created in tmpdir() and will also be removed at program exit. |
918 | 510 | |
919 | 511 | =end original |
920 | 512 | |
921 | 513 | 一時ディレクトリを提供されたテンプレートを使って作成しますが、 |
922 | 514 | プログラムが終了するときに、そのディレクトリ(およびその中の全てのファイル)を |
923 | 515 | 削除しようとします。 |
924 | 516 | この試みは、このモジュールが作っていないものも含めて、 |
925 | 517 | そのディレクトリから全てのファイルを削除しようとします |
926 | 518 | (さもなければなぜ削除するか尋ねますか?)。 |
927 | 519 | ディレクトリの除去は L<File::Path|File::Path> の rmtree() 関数で |
928 | 520 | 行なわれます。 |
929 | 521 | もちろん、テンプレートが指定されていなければ、 |
930 | 522 | 一時ディレクトリは tempdir() に作られ、プログラムの終了時に削除されます。 |
931 | 523 | |
932 | =begin original | |
933 | ||
934 | Will croak() if there is an error. | |
935 | ||
936 | =end original | |
937 | ||
938 | エラーがあると croak() します。 | |
939 | ||
940 | =cut | |
941 | ||
942 | 524 | =back |
943 | 525 | |
944 | 526 | =head1 MKTEMP FUNCTIONS |
945 | 527 | |
946 | 528 | (MKTEMP 関数) |
947 | 529 | |
948 | 530 | =begin original |
949 | 531 | |
950 | The following functions are Perl implementations of the | |
532 | The following functions are Perl implementations of the | |
951 | 533 | mktemp() family of temp file generation system calls. |
952 | 534 | |
953 | 535 | =end original |
954 | 536 | |
955 | 537 | 以下の関数は、一時ファイルを生成するシステムコールである |
956 | 538 | mktemp() の仲間の Perl の実装です。 |
957 | 539 | |
958 | 540 | =over 4 |
959 | 541 | |
960 | 542 | =item B<mkstemp> |
961 | 543 | |
962 | 544 | =begin original |
963 | 545 | |
964 | 546 | Given a template, returns a filehandle to the temporary file and the name |
965 | 547 | of the file. |
966 | 548 | |
967 | 549 | =end original |
968 | 550 | |
969 | 551 | テンプレートを与えると、一時ファイルのファイルハンドルとファイル名を返します。 |
970 | 552 | |
971 | 553 | ($fh, $name) = mkstemp( $template ); |
972 | 554 | |
973 | 555 | =begin original |
974 | 556 | |
975 | 557 | In scalar context, just the filehandle is returned. |
976 | 558 | |
977 | 559 | =end original |
978 | 560 | |
979 | 561 | スカラコンテキストでは、ファイルハンドルだけが返されます。 |
980 | 562 | |
981 | 563 | =begin original |
982 | 564 | |
983 | 565 | The template may be any filename with some number of X's appended |
984 | 566 | to it, for example F</tmp/temp.XXXX>. The trailing X's are replaced |
985 | 567 | with unique alphanumeric combinations. |
986 | 568 | |
987 | 569 | =end original |
988 | 570 | |
989 | 571 | テンプレートは、いくつかの `X' が追加されたファイル名かもしれません; |
990 | 572 | 例えば F</tmp/tmp.XXXX>。 |
991 | 573 | 末尾の X は、ユニークな英数字の組合せに置き換えられます。 |
992 | 574 | |
993 | =begin original | |
994 | ||
995 | Will croak() if there is an error. | |
996 | ||
997 | =end original | |
998 | ||
999 | エラーがあると croak() します。 | |
1000 | ||
1001 | =cut | |
1002 | ||
1003 | 575 | =item B<mkstemps> |
1004 | 576 | |
1005 | 577 | =begin original |
1006 | 578 | |
1007 | 579 | Similar to mkstemp(), except that an extra argument can be supplied |
1008 | 580 | with a suffix to be appended to the template. |
1009 | 581 | |
1010 | 582 | =end original |
1011 | 583 | |
584 | ||
1012 | 585 | mkstemp() に似ていますが、特別な引数を与えて、 |
1013 | 586 | テンプレートに接尾辞を追加できます。 |
1014 | 587 | |
1015 | 588 | ($fh, $name) = mkstemps( $template, $suffix ); |
1016 | 589 | |
1017 | 590 | =begin original |
1018 | 591 | |
1019 | 592 | For example a template of C<testXXXXXX> and suffix of C<.dat> |
1020 | 593 | would generate a file similar to F<testhGji_w.dat>. |
1021 | 594 | |
1022 | 595 | =end original |
1023 | 596 | |
1024 | 597 | 例えば、テンプレート が C<testXXXXXX> で接尾辞が C<.dat> なら、 |
1025 | 598 | F<testthGji_w.dat> のようなファイルを生成します。 |
1026 | 599 | |
1027 | 600 | =begin original |
1028 | 601 | |
1029 | 602 | Returns just the filehandle alone when called in scalar context. |
1030 | 603 | |
1031 | 604 | =end original |
1032 | 605 | |
1033 | 606 | スカラコンテキストで呼ばれると、ただファイル名だけを返します。 |
1034 | 607 | |
1035 | =begin original | |
1036 | ||
1037 | Will croak() if there is an error. | |
1038 | ||
1039 | =end original | |
1040 | ||
1041 | エラーがあると croak() します。 | |
1042 | ||
1043 | =cut | |
1044 | ||
1045 | 608 | =item B<mkdtemp> |
1046 | 609 | |
1047 | 610 | =begin original |
1048 | 611 | |
1049 | 612 | Create a directory from a template. The template must end in |
1050 | 613 | X's that are replaced by the routine. |
1051 | 614 | |
1052 | 615 | =end original |
1053 | 616 | |
1054 | 617 | テンプレートからディレクトリを作成します。 |
1055 | 618 | ルーチンによって置き換えられるテンプレートは、 |
1056 | 619 | 複数の X で終っていなければなりません。 |
1057 | 620 | |
1058 | 621 | $tmpdir_name = mkdtemp($template); |
1059 | 622 | |
1060 | 623 | =begin original |
1061 | 624 | |
1062 | 625 | Returns the name of the temporary directory created. |
626 | Returns undef on failure. | |
1063 | 627 | |
1064 | 628 | =end original |
1065 | 629 | |
1066 | 630 | 作成された一時ディレクトリの名前を返します。 |
631 | 失敗すると undef を返します。 | |
1067 | 632 | |
1068 | 633 | =begin original |
1069 | 634 | |
1070 | 635 | Directory must be removed by the caller. |
1071 | 636 | |
1072 | 637 | =end original |
1073 | 638 | |
1074 | 639 | ディレクトリは、呼び出し元で削除しなければなりません。 |
1075 | 640 | |
1076 | =begin original | |
1077 | ||
1078 | Will croak() if there is an error. | |
1079 | ||
1080 | =end original | |
1081 | ||
1082 | エラーがあると croak() します。 | |
1083 | ||
1084 | =cut | |
1085 | ||
1086 | 641 | =item B<mktemp> |
1087 | 642 | |
1088 | 643 | =begin original |
1089 | 644 | |
1090 | 645 | Returns a valid temporary filename but does not guarantee |
1091 | 646 | that the file will not be opened by someone else. |
1092 | 647 | |
1093 | 648 | =end original |
1094 | 649 | |
1095 | 妥当な一時ファイル名を返します | |
650 | 妥当な一時ファイル名を返します。 | |
1096 | 開かれていないことは保証しません。 | |
651 | ですが、そのファイルが、他の誰かに開かれていないことは保証しません。 | |
1097 | 652 | |
1098 | 653 | $unopened_file = mktemp($template); |
1099 | 654 | |
1100 | 655 | =begin original |
1101 | 656 | |
1102 | 657 | Template is the same as that required by mkstemp(). |
1103 | 658 | |
1104 | 659 | =end original |
1105 | 660 | |
1106 | 661 | テンプレートは、mkstemp() で必要とされるのと同じです。 |
1107 | 662 | |
1108 | =begin original | |
1109 | ||
1110 | Will croak() if there is an error. | |
1111 | ||
1112 | =end original | |
1113 | ||
1114 | エラーがあると croak() します。 | |
1115 | ||
1116 | =cut | |
1117 | ||
1118 | 663 | =back |
1119 | 664 | |
1120 | 665 | =head1 POSIX FUNCTIONS |
1121 | 666 | |
1122 | 667 | (POSIX 関数) |
1123 | 668 | |
1124 | 669 | =begin original |
1125 | 670 | |
1126 | 671 | This section describes the re-implementation of the tmpnam() |
1127 | and tmpfile() functions described in L<POSIX> | |
672 | and tmpfile() functions described in L<POSIX> | |
1128 | 673 | using the mkstemp() from this module. |
1129 | 674 | |
1130 | 675 | =end original |
1131 | 676 | |
1132 | 677 | この節は、このモジュールから mkstemp() を使っている、L<POSIX> に |
1133 | 678 | 説明されている tmpnam() と tmpfile() 関数の再実装を説明しています。 |
1134 | 679 | |
1135 | 680 | =begin original |
1136 | 681 | |
1137 | 682 | Unlike the L<POSIX|POSIX> implementations, the directory used |
1138 | 683 | for the temporary file is not specified in a system include |
1139 | 684 | file (C<P_tmpdir>) but simply depends on the choice of tmpdir() |
1140 | 685 | returned by L<File::Spec|File::Spec>. On some implementations this |
1141 | 686 | location can be set using the C<TMPDIR> environment variable, which |
1142 | 687 | may not be secure. |
1143 | 688 | If this is a problem, simply use mkstemp() and specify a template. |
1144 | 689 | |
1145 | 690 | =end original |
1146 | 691 | |
1147 | 692 | L<POSIX|POSIX> の実装とは違い、一時ファイルに使われるディレクトリは、 |
1148 | 693 | システム内部のファイル (C<P_tmpdir>) で指定されているのではなく、 |
1149 | 694 | 単純に、L<File::Spec|File::Spec> によって、tmpdir() が返すものの選択に |
1150 | 695 | 依っています。 |
1151 | 実装によっては、この場所は、 | |
696 | 実装によっては、この場所は、C<TMPDIR> 環境変数を使って | |
1152 | ||
697 | 設定されているかもしれません、これは安全ではないかもしれません。 | |
1153 | 698 | このことが問題なら、単純に、mkstemp() を使い、テンプレートを指定して下さい。 |
1154 | 699 | |
1155 | 700 | =over 4 |
1156 | 701 | |
1157 | 702 | =item B<tmpnam> |
1158 | 703 | |
1159 | 704 | =begin original |
1160 | 705 | |
1161 | 706 | When called in scalar context, returns the full name (including path) |
1162 | 707 | of a temporary file (uses mktemp()). The only check is that the file does |
1163 | 708 | not already exist, but there is no guarantee that that condition will |
1164 | 709 | continue to apply. |
1165 | 710 | |
1166 | 711 | =end original |
1167 | 712 | |
1168 | 713 | スカラコンテキストで呼ばれたら、(mktemp() を使う)一時ファイルの |
1169 | 714 | (パスを含んだ)フルネームを返します。 |
1170 | 715 | ファイルが既に存在しないことだけをチェックしますが、 |
1171 | 716 | その状態が適用され続ける保証はありません。 |
1172 | 717 | |
1173 | 718 | $file = tmpnam(); |
1174 | 719 | |
1175 | 720 | =begin original |
1176 | 721 | |
1177 | 722 | When called in list context, a filehandle to the open file and |
1178 | 723 | a filename are returned. This is achieved by calling mkstemp() |
1179 | 724 | after constructing a suitable template. |
1180 | 725 | |
1181 | 726 | =end original |
1182 | 727 | |
1183 | 728 | リストコンテキストで呼ばれると、ファイルを開くファイルハンドルと |
1184 | 729 | ファイル名が返ります。 |
1185 | 730 | これは、適切なテンプレートを組み立てた後に mkstemp() を呼ぶことで |
1186 | 731 | 達成されます。 |
1187 | 732 | |
1188 | 733 | ($fh, $file) = tmpnam(); |
1189 | 734 | |
1190 | 735 | =begin original |
1191 | 736 | |
1192 | 737 | If possible, this form should be used to prevent possible |
1193 | 738 | race conditions. |
1194 | 739 | |
1195 | 740 | =end original |
1196 | 741 | |
1197 | 742 | 可能なら、潜在的な競合状態を防ぐためにこの形で使うべきです。 |
1198 | 743 | |
1199 | 744 | =begin original |
1200 | 745 | |
1201 | 746 | See L<File::Spec/tmpdir> for information on the choice of temporary |
1202 | 747 | directory for a particular operating system. |
1203 | 748 | |
1204 | 749 | =end original |
1205 | 750 | |
1206 | 751 | 特定のオペレーティングシステムで |
1207 | 752 | 一時ディレクトリを選択するための情報については、 |
1208 | 753 | L<File::Spec/tmpdir> を参照してください。 |
1209 | 754 | |
1210 | =begin original | |
1211 | ||
1212 | Will croak() if there is an error. | |
1213 | ||
1214 | =end original | |
1215 | ||
1216 | エラーがあると croak() します。 | |
1217 | ||
1218 | =cut | |
1219 | ||
1220 | 755 | =item B<tmpfile> |
1221 | 756 | |
1222 | 757 | =begin original |
1223 | 758 | |
1224 | ||
759 | In scalar context, returns the filehandle of a temporary file. | |
1225 | 760 | |
1226 | 761 | =end original |
1227 | 762 | |
1228 | 一時ファイルのファイルハンドルを返します。 | |
763 | スカラコンテキストでは、一時ファイルのファイルハンドルを返します。 | |
1229 | 764 | |
1230 | 765 | $fh = tmpfile(); |
1231 | 766 | |
1232 | 767 | =begin original |
1233 | 768 | |
1234 | 769 | The file is removed when the filehandle is closed or when the program |
1235 | 770 | exits. No access to the filename is provided. |
1236 | 771 | |
1237 | 772 | =end original |
1238 | 773 | |
1239 | 774 | ファイルハンドルが閉じられるときか、プログラムが終了するときに、 |
1240 | 775 | ファイルは削除されます。 |
1241 | 776 | ファイル名へのアクセスは提供されていません。 |
1242 | 777 | |
1243 | 778 | =begin original |
1244 | 779 | |
1245 | 780 | If the temporary file can not be created undef is returned. |
1246 | 781 | Currently this command will probably not work when the temporary |
1247 | 782 | directory is on an NFS file system. |
1248 | 783 | |
1249 | 784 | =end original |
1250 | 785 | |
1251 | 786 | 一時ファイルが作られなければ、undef が返ります。 |
1252 | 787 | 一時ディレクトリが NFS ファイルシステムの場合、 |
1253 | 788 | 現在のところこのコマンドはおそらく動きません。 |
1254 | 789 | |
1255 | =begin original | |
1256 | ||
1257 | Will croak() if there is an error. | |
1258 | ||
1259 | =end original | |
1260 | ||
1261 | エラーがあると croak() します。 | |
1262 | ||
1263 | =cut | |
1264 | ||
1265 | 790 | =back |
1266 | 791 | |
1267 | 792 | =head1 ADDITIONAL FUNCTIONS |
1268 | 793 | |
1269 | 794 | (追加の関数) |
1270 | 795 | |
1271 | 796 | =begin original |
1272 | 797 | |
1273 | 798 | These functions are provided for backwards compatibility |
1274 | 799 | with common tempfile generation C library functions. |
1275 | 800 | |
1276 | 801 | =end original |
1277 | 802 | |
1278 | 803 | これらの関数は、共通の一時ファイル生成の C ライブラリ関数の |
1279 | 804 | 後方互換のために提供されています。 |
1280 | 805 | |
1281 | 806 | =begin original |
1282 | 807 | |
1283 | 808 | They are not exported and must be addressed using the full package |
1284 | name. | |
809 | name. | |
1285 | 810 | |
1286 | 811 | =end original |
1287 | 812 | |
1288 | 813 | エクスポートされていないので、完全なパッケージ名を使って |
1289 | 814 | 記述しなければなりません。 |
1290 | 815 | |
1291 | 816 | =over 4 |
1292 | 817 | |
1293 | 818 | =item B<tempnam> |
1294 | 819 | |
1295 | 820 | =begin original |
1296 | 821 | |
1297 | 822 | Return the name of a temporary file in the specified directory |
1298 | 823 | using a prefix. The file is guaranteed not to exist at the time |
1299 | the function was called, but such guarantees are good for one | |
824 | the function was called, but such guarantees are good for one | |
1300 | 825 | clock tick only. Always use the proper form of C<sysopen> |
1301 | 826 | with C<O_CREAT | O_EXCL> if you must open such a filename. |
1302 | 827 | |
1303 | 828 | =end original |
1304 | 829 | |
1305 | 830 | 接頭辞を使って指定したディレクトリ内に、一時ファイルのファイル名を返します。 |
1306 | 831 | ファイルは関数が呼ばれたそのときに存在していないことを保証されます。 |
1307 | 832 | ですが、この保証は一瞬だけのものです。 |
1308 | 833 | そのようなファイル名を開かなければならないなら、 |
1309 | 834 | C<O_CREAT | O_EXCL> で、C<sysopen> の適切な形を常に使ってください。 |
1310 | 835 | |
1311 | 836 | $filename = File::Temp::tempnam( $dir, $prefix ); |
1312 | 837 | |
1313 | 838 | =begin original |
1314 | 839 | |
1315 | 840 | Equivalent to running mktemp() with $dir/$prefixXXXXXXXX |
1316 | (using unix file convention as an example) | |
841 | (using unix file convention as an example) | |
1317 | 842 | |
1318 | 843 | =end original |
1319 | 844 | |
1320 | 845 | $dir/$prefixXXXXXXXXX で、mktemp() を実行するのと同じです。 |
1321 | 846 | (例として、unix のファイルの慣例を使います) |
1322 | 847 | |
1323 | 848 | =begin original |
1324 | 849 | |
1325 | 850 | Because this function uses mktemp(), it can suffer from race conditions. |
1326 | 851 | |
1327 | 852 | =end original |
1328 | 853 | |
1329 | 854 | この関数は mktemp() を使うので、競合状態の影響を受けます。 |
1330 | 855 | |
1331 | =begin original | |
1332 | ||
1333 | Will croak() if there is an error. | |
1334 | ||
1335 | =end original | |
1336 | ||
1337 | エラーがあると croak() します。 | |
1338 | ||
1339 | =cut | |
1340 | ||
1341 | 856 | =back |
1342 | 857 | |
1343 | 858 | =head1 UTILITY FUNCTIONS |
1344 | 859 | |
1345 | 860 | (ユーティリティ関数) |
1346 | 861 | |
1347 | 862 | =begin original |
1348 | 863 | |
1349 | 864 | Useful functions for dealing with the filehandle and filename. |
1350 | 865 | |
1351 | 866 | =end original |
1352 | 867 | |
1353 | 868 | ファイルハンドルとファイル名を扱うための便利関数。 |
1354 | 869 | |
1355 | 870 | =over 4 |
1356 | 871 | |
1357 | 872 | =item B<unlink0> |
1358 | 873 | |
1359 | 874 | =begin original |
1360 | 875 | |
1361 | 876 | Given an open filehandle and the associated filename, make a safe |
1362 | 877 | unlink. This is achieved by first checking that the filename and |
1363 | 878 | filehandle initially point to the same file and that the number of |
1364 | 879 | links to the file is 1 (all fields returned by stat() are compared). |
1365 | 880 | Then the filename is unlinked and the filehandle checked once again to |
1366 | 881 | verify that the number of links on that file is now 0. This is the |
1367 | 882 | closest you can come to making sure that the filename unlinked was the |
1368 | 883 | same as the file whose descriptor you hold. |
1369 | 884 | |
1370 | 885 | =end original |
1371 | 886 | |
1372 | 887 | 開いているファイルハンドルと、関連付けられたファイル名を与えると、 |
1373 | 888 | 安全に削除します。 |
1374 | 889 | これは、ファイル名とファイルハンドルが同じファイルを指し、 |
1375 | 890 | ファイルへのリンクの数が、一つであること |
1376 | 891 | (stat()が返す全てのフィールドが比較されます)を |
1377 | 892 | 最初にチェックすることで、実現します。 |
1378 | 893 | それからファイル名が削除されて、ファイルハンドルが再びチェックされ、 |
1379 | 894 | そのファイルのリンクの数が今度は 0 であることを検証します。 |
1380 | 895 | このことは、保持しているファイルのディスクリプタと削除されたファイル名が |
1381 | 896 | 同じであることを確かめるのに、最も周到です。 |
1382 | 897 | |
1383 | unlink0($fh, $path) | |
1384 | or die "Error unlinking file $path safely"; | |
1385 | ||
1386 | 898 | =begin original |
1387 | 899 | |
1388 | Returns false on error but croaks() if there is a security | |
1389 | anomaly. The filehandle is not closed since on some occasions this is | |
1390 | not required. | |
1391 | ||
1392 | =end original | |
1393 | ||
1394 | エラーのときは偽を返しますが、セキュリティ問題があった場合は croak() します。 | |
1395 | これが必要でない場合があるので、ファイルハンドルは閉じません。 | |
1396 | ||
1397 | =begin original | |
1398 | ||
1399 | 900 | On some platforms, for example Windows NT, it is not possible to |
1400 | 901 | unlink an open file (the file must be closed first). On those |
1401 | 902 | platforms, the actual unlinking is deferred until the program ends and |
1402 | 903 | good status is returned. A check is still performed to make sure that |
1403 | 904 | the filehandle and filename are pointing to the same thing (but not at |
1404 | 905 | the time the end block is executed since the deferred removal may not |
1405 | 906 | have access to the filehandle). |
1406 | 907 | |
1407 | 908 | =end original |
1408 | 909 | |
1409 | 910 | プラットフォームによっては(例えば、Windows NT)、開いているファイルを |
1410 | 911 | 削除できないものもあります |
1411 | 912 | (ファイルはまず閉じられなければいけません)。 |
1412 | 913 | それらのプラットフォームでは、プログラムが終了し、良い状態になるまで、 |
1413 | 914 | 実際の削除は据え置かれます。 |
1414 | 915 | ファイルハンドルとファイル名が同じのを指す事を確かめるまで、チェックは |
1415 | 916 | 行なわれます。 |
1416 | 917 | (しかし、最後のブロックが実行された時点でなければ、 |
1417 | 918 | 据え置かれた削除はファイルハンドルにアクセスしないでしょう。) |
1418 | 919 | |
1419 | 920 | =begin original |
1420 | 921 | |
1421 | 922 | Additionally, on Windows NT not all the fields returned by stat() can |
1422 | 923 | be compared. For example, the C<dev> and C<rdev> fields seem to be |
1423 | 924 | different. Also, it seems that the size of the file returned by stat() |
1424 | 925 | does not always agree, with C<stat(FH)> being more accurate than |
1425 | 926 | C<stat(filename)>, presumably because of caching issues even when |
1426 | 927 | using autoflush (this is usually overcome by waiting a while after |
1427 | 928 | writing to the tempfile before attempting to C<unlink0> it). |
1428 | 929 | |
1429 | 930 | =end original |
1430 | 931 | |
1431 | 932 | さらに、Windows NT は、stat() が比較される全てのフィールドを返しません。 |
1432 | 933 | 例えば、C<dev> と C<rdev> フィールドは異なっているようです。 |
1433 | 934 | また、stat() が返すファイルのサイズは、常には一致しません; |
1434 | 935 | C<stat(FH)> は、C<stat(filename)> よりも、狂いがありません; |
1435 | 936 | おそらく、例え自動フラッシュを使っていても、キャッシングの問題によるものです |
1436 | 937 | (これは普通、一時ファイルに書き込んだ後、それを C<unlink0> が試される前に |
1437 | 938 | しばらく待つことで、対処できます)。 |
1438 | 939 | |
1439 | 940 | =begin original |
1440 | 941 | |
1441 | 942 | Finally, on NFS file systems the link count of the file handle does |
1442 | 943 | not always go to zero immediately after unlinking. Currently, this |
1443 | 944 | command is expected to fail on NFS disks. |
1444 | 945 | |
1445 | 946 | =end original |
1446 | 947 | |
1447 | 最後に、NFS ファイルシステムでは、ファイルハンドルのリンクカウントは、 | |
948 | 最後に、NFS ファイルシステムでは、 ファイルハンドルのリンクカウントは、 | |
1448 | ||
949 | 削除の後、すぐには、常には 0 になりません。 | |
1449 | 現在 | |
950 | 現在このコマンドは、NFS ディスク上では失敗すると想定されます。 | |
1450 | 951 | |
1451 | =begin original | |
1452 | ||
1453 | This function is disabled if the global variable $KEEP_ALL is true | |
1454 | and an unlink on open file is supported. If the unlink is to be deferred | |
1455 | to the END block, the file is still registered for removal. | |
1456 | ||
1457 | =end original | |
1458 | ||
1459 | グローバル変数 $KEEP_ALL が真で、開いているファイルの | |
1460 | 削除に対応している場合、この関数は無効になります。 | |
1461 | 削除が END ブロックまで遅延される場合、このファイルは | |
1462 | 削除のために登録されたままです。 | |
1463 | ||
1464 | =begin original | |
1465 | ||
1466 | This function should not be called if you are using the object oriented | |
1467 | interface since the it will interfere with the object destructor deleting | |
1468 | the file. | |
1469 | ||
1470 | =end original | |
1471 | ||
1472 | この関数はファイルを削除するオブジェクトデストラクタを妨害するので、 | |
1473 | オブジェクト指向インターフェースを使っている場合はこの関数は | |
1474 | 呼び出されるべきではありません。 | |
1475 | ||
1476 | =cut | |
1477 | ||
1478 | =item B<cmpstat> | |
1479 | ||
1480 | =begin original | |
1481 | ||
1482 | Compare C<stat> of filehandle with C<stat> of provided filename. This | |
1483 | can be used to check that the filename and filehandle initially point | |
1484 | to the same file and that the number of links to the file is 1 (all | |
1485 | fields returned by stat() are compared). | |
1486 | ||
1487 | =end original | |
1488 | ||
1489 | ファイルハンドルの C<stat> を、指定されたファイル名の C<stat> と比較します。 | |
1490 | これは、 | |
1491 | まずファイル名とファイルハンドルが同じファイルを指していて、 | |
1492 | そのファイルへのリンクの数が 1 であることをチェックするのに使えます。 | |
1493 | (stat() によって返された全てのフィールドが比較されます)。 | |
1494 | ||
1495 | cmpstat($fh, $path) | |
1496 | or die "Error comparing handle with file"; | |
1497 | ||
1498 | =begin original | |
1499 | ||
1500 | Returns false if the stat information differs or if the link count is | |
1501 | greater than 1. Calls croak if there is a security anomaly. | |
1502 | ||
1503 | =end original | |
1504 | ||
1505 | stat 情報が異なるか、リンクカウントが 1 より大きい場合は、偽を返します。 | |
1506 | セキュリティ上の異常があると croak を呼び出します。 | |
1507 | ||
1508 | =begin original | |
1509 | ||
1510 | On certain platforms, for example Windows, not all the fields returned by stat() | |
1511 | can be compared. For example, the C<dev> and C<rdev> fields seem to be | |
1512 | different in Windows. Also, it seems that the size of the file | |
1513 | returned by stat() does not always agree, with C<stat(FH)> being more | |
1514 | accurate than C<stat(filename)>, presumably because of caching issues | |
1515 | even when using autoflush (this is usually overcome by waiting a while | |
1516 | after writing to the tempfile before attempting to C<unlink0> it). | |
1517 | ||
1518 | =end original | |
1519 | ||
1520 | 例えば Windows のような、一部のプラットフォームでは、 | |
1521 | stat() によって返された全てのフィールドを比較することはできません。 | |
1522 | 例えば、Windows では C<dev> と C<rdev> フィールドは異なっているように | |
1523 | 見えます。 | |
1524 | また、stat() によって返されるファイルサイズは常には一致しません; | |
1525 | C<stat(FH)> は C<stat(filename)> より正確になります; | |
1526 | おそらく、たとえ autoflush を使ってもキャッシュ問題のためです | |
1527 | (これは普通、一時ファイルを書いた後、C<unlink0> を試みる前に、 | |
1528 | しばらく待つことで克服されます)。 | |
1529 | ||
1530 | =begin original | |
1531 | ||
1532 | Not exported by default. | |
1533 | ||
1534 | =end original | |
1535 | ||
1536 | デフォルトではエクスポートされません。 | |
1537 | ||
1538 | =cut | |
1539 | ||
1540 | =item B<unlink1> | |
1541 | ||
1542 | =begin original | |
1543 | ||
1544 | Similar to C<unlink0> except after file comparison using cmpstat, the | |
1545 | filehandle is closed prior to attempting to unlink the file. This | |
1546 | allows the file to be removed without using an END block, but does | |
1547 | mean that the post-unlink comparison of the filehandle state provided | |
1548 | by C<unlink0> is not available. | |
1549 | ||
1550 | =end original | |
1551 | ||
1552 | C<unlink0> と同様ですが、cmpstat を使ってファイルを比較した後、 | |
1553 | ファイルを削除しようとする前にファイルを閉じます。 | |
1554 | これにより、END ブロックを使わずにファイルを削除できるようになりますが、 | |
1555 | これは、C<unlink0> によって提供される、ファイルハンドル状態の | |
1556 | unlink 後の比較は利用できなくなるということです。 | |
1557 | ||
1558 | unlink1($fh, $path) | |
1559 | or die "Error closing and unlinking file"; | |
1560 | ||
1561 | =begin original | |
1562 | ||
1563 | Usually called from the object destructor when using the OO interface. | |
1564 | ||
1565 | =end original | |
1566 | ||
1567 | 通常は、OO インターフェースを使うときにオブジェクトのデストラクタから | |
1568 | 呼び出されます。 | |
1569 | ||
1570 | =begin original | |
1571 | ||
1572 | Not exported by default. | |
1573 | ||
1574 | =end original | |
1575 | ||
1576 | デフォルトではエクスポートされません。 | |
1577 | ||
1578 | =begin original | |
1579 | ||
1580 | This function is disabled if the global variable $KEEP_ALL is true. | |
1581 | ||
1582 | =end original | |
1583 | ||
1584 | この関数は、$KEEP_ALL が真の場合は無効になります。 | |
1585 | ||
1586 | =begin original | |
1587 | ||
1588 | Can call croak() if there is a security anomaly during the stat() | |
1589 | comparison. | |
1590 | ||
1591 | =end original | |
1592 | ||
1593 | stat() 比較のときにセキュリティの問題がある場合は croak() を | |
1594 | 呼ぶことがあります。 | |
1595 | ||
1596 | =cut | |
1597 | ||
1598 | =item B<cleanup> | |
1599 | ||
1600 | =begin original | |
1601 | ||
1602 | Calling this function will cause any temp files or temp directories | |
1603 | that are registered for removal to be removed. This happens automatically | |
1604 | when the process exits but can be triggered manually if the caller is sure | |
1605 | that none of the temp files are required. This method can be registered as | |
1606 | an Apache callback. | |
1607 | ||
1608 | =end original | |
1609 | ||
1610 | この関数を呼び出すと、削除すると登録された全ての一時ファイルや | |
1611 | 一時ディレクトリが削除されます。 | |
1612 | これはプロセスの終了時に自動的に行われますが、 | |
1613 | 呼び出し元が一時ファイルを必要としていないことを確実にしたい場合は | |
1614 | 手動で引き起こすこともできます。 | |
1615 | このメソッドは Apache のコールバックとして登録できます。 | |
1616 | ||
1617 | =begin original | |
1618 | ||
1619 | On OSes where temp files are automatically removed when the temp file | |
1620 | is closed, calling this function will have no effect other than to remove | |
1621 | temporary directories (which may include temporary files). | |
1622 | ||
1623 | =end original | |
1624 | ||
1625 | 一時ファイルが閉じられたときに一時ファイルが自動的に削除される OS では、 | |
1626 | この関数を呼び出しても、 | |
1627 | (一時ファイルが含まれているかもしれない)一時ディレクトリを削除する以外に | |
1628 | 何の効果もありません。 | |
1629 | ||
1630 | File::Temp::cleanup(); | |
1631 | ||
1632 | =begin original | |
1633 | ||
1634 | Not exported by default. | |
1635 | ||
1636 | =end original | |
1637 | ||
1638 | デフォルトではエクスポートされません。 | |
1639 | ||
1640 | 952 | =back |
1641 | 953 | |
1642 | 954 | =head1 PACKAGE VARIABLES |
1643 | 955 | |
1644 | 956 | (パッケージ変数) |
1645 | 957 | |
1646 | 958 | =begin original |
1647 | 959 | |
1648 | 960 | These functions control the global state of the package. |
1649 | 961 | |
1650 | 962 | =end original |
1651 | 963 | |
1652 | 964 | これらの関数は、パッケージのグローバルな状態を制御します。 |
1653 | 965 | |
1654 | 966 | =over 4 |
1655 | 967 | |
1656 | 968 | =item B<safe_level> |
1657 | 969 | |
1658 | 970 | =begin original |
1659 | 971 | |
1660 | 972 | Controls the lengths to which the module will go to check the safety of the |
1661 | 973 | temporary file or directory before proceeding. |
1662 | 974 | Options are: |
1663 | 975 | |
1664 | 976 | =end original |
1665 | 977 | |
1666 | 978 | このモジュールが処理前に一時ファイルか一時ディレクトリを |
1667 | 979 | 安全にチェックしようとする程度を制御します。 |
1668 | 980 | オプション: |
1669 | 981 | |
1670 | 982 | =over 8 |
1671 | 983 | |
1672 | 984 | =item STANDARD |
1673 | 985 | |
1674 | 986 | =begin original |
1675 | 987 | |
1676 | Do the basic security measures to ensure the directory exists and | |
988 | Do the basic security measures to ensure the directory exists and | |
1677 | writable, that tem | |
989 | is writable, that the umask() is fixed before opening of the file, | |
1678 | ||
990 | that temporary files are opened only if they do not already exist, and | |
1679 | ||
991 | that possible race conditions are avoided. Finally the L<unlink0|"unlink0"> | |
992 | function is used to remove files safely. | |
1680 | 993 | |
1681 | 994 | =end original |
1682 | 995 | |
1683 | 996 | 基本的なセキュリティの程度で、以下のことを保証します; |
1684 | 997 | ディレクトリが存在し、書き込み可能であること; |
998 | ファイルを開く前に、umask() が固定されていること; | |
1685 | 999 | 一時ファイルは、まだ存在していない場合にのみ開いていて、競合条件が |
1686 | 1000 | 避けられていること。 |
1687 | 1001 | 最後に、ファイルを安全に削除するために |
1688 | 1002 | L<unlink0|"unlink0"> 関数が使われます。 |
1689 | 1003 | |
1690 | 1004 | =item MEDIUM |
1691 | 1005 | |
1692 | 1006 | =begin original |
1693 | 1007 | |
1694 | 1008 | In addition to the STANDARD security, the output directory is checked |
1695 | 1009 | to make sure that it is owned either by root or the user running the |
1696 | 1010 | program. If the directory is writable by group or by other, it is then |
1697 | 1011 | checked to make sure that the sticky bit is set. |
1698 | 1012 | |
1699 | 1013 | =end original |
1700 | 1014 | |
1701 | 1015 | STANDARD の安全性に加えて、出力ディレクトリが root または |
1702 | 1016 | プログラムを実行しているユーザのどちらかによって |
1703 | 1017 | 所有されていることを確かめるチェックをします。 |
1704 | 1018 | ディレクトリが他のグループかユーザによって書き込み可能であるならば、 |
1705 | 1019 | スティッキービットがセットされていることを確かめるチェックをします。 |
1706 | 1020 | |
1707 | 1021 | =begin original |
1708 | 1022 | |
1709 | 1023 | Will not work on platforms that do not support the C<-k> test |
1710 | 1024 | for sticky bit. |
1711 | 1025 | |
1712 | 1026 | =end original |
1713 | 1027 | |
1714 | 1028 | スティッキービットのための C<-k> テストに対応していないプラットフォームでは |
1715 | 1029 | 動作しません。 |
1716 | 1030 | |
1031 | ||
1717 | 1032 | =item HIGH |
1718 | 1033 | |
1719 | 1034 | =begin original |
1720 | 1035 | |
1721 | 1036 | In addition to the MEDIUM security checks, also check for the |
1722 | 1037 | possibility of ``chown() giveaway'' using the L<POSIX|POSIX> |
1723 | 1038 | sysconf() function. If this is a possibility, each directory in the |
1724 | path is checked in turn for safeness, recursively walking back to the | |
1039 | path is checked in turn for safeness, recursively walking back to the | |
1725 | 1040 | root directory. |
1726 | 1041 | |
1727 | 1042 | =end original |
1728 | 1043 | |
1729 | 1044 | MEDIUM の安全性チェックに加えて、L<POSIX|POSIX> sysconf() 関数を使って、 |
1730 | 1045 | ``chown() giveaway'' の可能性もチェックします。 |
1731 | 1046 | もしこの可能性があれば、それぞれのパスのディレクトリは、 |
1732 | 1047 | ルートディレクトリまで再帰的に安全性がチェックされます。 |
1733 | 1048 | |
1734 | 1049 | =begin original |
1735 | 1050 | |
1736 | 1051 | For platforms that do not support the L<POSIX|POSIX> |
1737 | C<_PC_CHOWN_RESTRICTED> symbol (for example, Windows NT) it is | |
1052 | C<_PC_CHOWN_RESTRICTED> symbol (for example, Windows NT) it is | |
1738 | 1053 | assumed that ``chown() giveaway'' is possible and the recursive test |
1739 | 1054 | is performed. |
1740 | 1055 | |
1741 | 1056 | =end original |
1742 | 1057 | |
1743 | 1058 | L<POSIX|POSIX> の C<_PC_CHOWN_RESTRICTED> シンボルに対応しない |
1744 | 1059 | プラットフォーム(たとえば、Windows NT)では、 |
1745 | 1060 | `chown() giveaway'' が可能であると仮定し、再帰的なテストが行われます。 |
1746 | 1061 | |
1747 | 1062 | =back |
1748 | 1063 | |
1749 | 1064 | =begin original |
1750 | 1065 | |
1751 | 1066 | The level can be changed as follows: |
1752 | 1067 | |
1753 | 1068 | =end original |
1754 | 1069 | |
1755 | 1070 | レベルは以下のようにして変更できます: |
1756 | 1071 | |
1757 | 1072 | File::Temp->safe_level( File::Temp::HIGH ); |
1758 | 1073 | |
1759 | 1074 | =begin original |
1760 | 1075 | |
1761 | 1076 | The level constants are not exported by the module. |
1762 | 1077 | |
1763 | 1078 | =end original |
1764 | 1079 | |
1765 | 1080 | レベル定数はモジュールによってエクスポートされません。 |
1766 | 1081 | |
1767 | 1082 | =begin original |
1768 | 1083 | |
1769 | 1084 | Currently, you must be running at least perl v5.6.0 in order to |
1770 | run with MEDIUM or HIGH security. This is simply because the | |
1085 | run with MEDIUM or HIGH security. This is simply because the | |
1771 | 1086 | safety tests use functions from L<Fcntl|Fcntl> that are not |
1772 | 1087 | available in older versions of perl. The problem is that the version |
1773 | 1088 | number for Fcntl is the same in perl 5.6.0 and in 5.005_03 even though |
1774 | 1089 | they are different versions. |
1775 | 1090 | |
1776 | 1091 | =end original |
1777 | 1092 | |
1778 | 1093 | MEDIUM か HIGH のセキュリティを実行するためには、 |
1779 | 1094 | 今のところ少なくとも Perl v5.6.0 で動かさなければなりません。 |
1780 | 1095 | これは単純に、安全なテストは v5.6.0 より古いバージョンの perl では |
1781 | 1096 | 利用できない <Fcntl|Fcntl> から関数を使うからです。 |
1782 | 1097 | perl 5.6.0 と、5.005_03 の Fcntl のバージョン番号が、それらは |
1783 | 1098 | 違うものであるにもかかわらず、 |
1784 | 1099 | バージョン番号が同じであることが問題です。 |
1785 | 1100 | |
1786 | 1101 | =begin original |
1787 | 1102 | |
1788 | 1103 | On systems that do not support the HIGH or MEDIUM safety levels |
1789 | 1104 | (for example Win NT or OS/2) any attempt to change the level will |
1790 | 1105 | be ignored. The decision to ignore rather than raise an exception |
1791 | 1106 | allows portable programs to be written with high security in mind |
1792 | 1107 | for the systems that can support this without those programs failing |
1793 | 1108 | on systems where the extra tests are irrelevant. |
1794 | 1109 | |
1795 | 1110 | =end original |
1796 | 1111 | |
1797 | 1112 | HIGH と、MEDIUM の安全レベルをサポートしない OS(Win NT や OS/2) では、 |
1798 | 1113 | レベルを変更しようとしても無視されます。 |
1799 | 1114 | 例外を起こさずに無視すると言う決定により、 |
1800 | 1115 | 移植性のあるプログラムを、 |
1801 | 1116 | 追加のテストが無意味であるシステムでプログラムが失敗するということなしに、 |
1802 | 1117 | 高い安全性に対応することができるシステムのことを考えて、 |
1803 | 1118 | 高いセキュリティで書くことを可能にします。 |
1804 | 1119 | |
1805 | 1120 | =begin original |
1806 | 1121 | |
1807 | 1122 | If you really need to see whether the change has been accepted |
1808 | 1123 | simply examine the return value of C<safe_level>. |
1809 | 1124 | |
1810 | 1125 | =end original |
1811 | 1126 | |
1812 | 1127 | もし、実際に変更が受け入れられたかどうかを確認する必要があるなら、 |
1813 | 1128 | 単に C<safe_level> の返り値をを調べてください。 |
1814 | 1129 | |
1815 | 1130 | $newlevel = File::Temp->safe_level( File::Temp::HIGH ); |
1816 | die "Could not change to high security" | |
1131 | die "Could not change to high security" | |
1817 | 1132 | if $newlevel != File::Temp::HIGH; |
1818 | 1133 | |
1819 | =cut | |
1820 | ||
1821 | 1134 | =item TopSystemUID |
1822 | 1135 | |
1823 | 1136 | =begin original |
1824 | 1137 | |
1825 | 1138 | This is the highest UID on the current system that refers to a root |
1826 | UID. This is used to make sure that the temporary directory is | |
1139 | UID. This is used to make sure that the temporary directory is | |
1827 | owned by a system UID (C<root>, C<bin>, C<sys> etc) rather than | |
1140 | owned by a system UID (C<root>, C<bin>, C<sys> etc) rather than | |
1828 | 1141 | simply by root. |
1829 | 1142 | |
1830 | 1143 | =end original |
1831 | 1144 | |
1832 | 1145 | これは root UID を参照する現在のシステムでもっとも高い UID です。 |
1833 | 1146 | これは一時ディレクトリが単純に root のものであるのではなくて、 |
1834 | 1147 | システム UID のもの(C<root>, C<bin>, C<sys> など)であることを確かめるのに、 |
1835 | 1148 | 使われます。 |
1836 | 1149 | |
1837 | 1150 | =begin original |
1838 | 1151 | |
1839 | 1152 | This is required since on many unix systems C</tmp> is not owned |
1840 | 1153 | by root. |
1841 | 1154 | |
1842 | 1155 | =end original |
1843 | 1156 | |
1844 | 1157 | 多くの unix のシステムで、C</tmp> は root のものではないので、 |
1845 | 1158 | これが必要とされます。 |
1846 | 1159 | |
1847 | 1160 | =begin original |
1848 | 1161 | |
1849 | 1162 | Default is to assume that any UID less than or equal to 10 is a root |
1850 | 1163 | UID. |
1851 | 1164 | |
1852 | 1165 | =end original |
1853 | 1166 | |
1854 | 1167 | デフォルトでは、10 以下のものはどんな UID も root UID と想定します。 |
1855 | 1168 | |
1856 | 1169 | File::Temp->top_system_uid(10); |
1857 | 1170 | my $topid = File::Temp->top_system_uid; |
1858 | 1171 | |
1859 | 1172 | =begin original |
1860 | 1173 | |
1861 | 1174 | This value can be adjusted to reduce security checking if required. |
1862 | 1175 | The value is only relevant when C<safe_level> is set to MEDIUM or higher. |
1863 | 1176 | |
1864 | 1177 | =end original |
1865 | 1178 | |
1866 | 1179 | 必要ならばこの値を調整してセキュリティチェックを下げることもできます。 |
1867 | 1180 | この値は C<safe_level> がMEDIUM 以上に設定されている場合に関連があります。 |
1868 | 1181 | |
1869 | =cut | |
1870 | ||
1871 | =item B<$KEEP_ALL> | |
1872 | ||
1873 | =begin original | |
1874 | ||
1875 | Controls whether temporary files and directories should be retained | |
1876 | regardless of any instructions in the program to remove them | |
1877 | automatically. This is useful for debugging but should not be used in | |
1878 | production code. | |
1879 | ||
1880 | =end original | |
1881 | ||
1882 | プログラムが一時ファイルやディレクトリを自動的に削除しようとする | |
1883 | 操作をしても、それらを残したままにするかどうかを制御します。 | |
1884 | これはデバッグには有用ですが、本番コードで用いるべきではありません。 | |
1885 | ||
1886 | $File::Temp::KEEP_ALL = 1; | |
1887 | ||
1888 | =begin original | |
1889 | ||
1890 | Default is for files to be removed as requested by the caller. | |
1891 | ||
1892 | =end original | |
1893 | ||
1894 | デフォルトは、呼び出し元によって要求された場合にファイルを削除します。 | |
1895 | ||
1896 | =begin original | |
1897 | ||
1898 | In some cases, files will only be retained if this variable is true | |
1899 | when the file is created. This means that you can not create a temporary | |
1900 | file, set this variable and expect the temp file to still be around | |
1901 | when the program exits. | |
1902 | ||
1903 | =end original | |
1904 | ||
1905 | 場合によっては、ファイルが作られた時点でこの変数が真の場合にのみ | |
1906 | ファイルが残されます。 | |
1907 | つまり、一時ファイルを作って、この変数を設定しても、 | |
1908 | プログラムが終了したときにこの一時ファイルがまだ残っていることを | |
1909 | 想定できないということです。 | |
1910 | ||
1911 | =item B<$DEBUG> | |
1912 | ||
1913 | =begin original | |
1914 | ||
1915 | Controls whether debugging messages should be enabled. | |
1916 | ||
1917 | =end original | |
1918 | ||
1919 | デバッグメッセージを有効にするかどうかを制御します。 | |
1920 | ||
1921 | $File::Temp::DEBUG = 1; | |
1922 | ||
1923 | =begin original | |
1924 | ||
1925 | Default is for debugging mode to be disabled. | |
1926 | ||
1927 | =end original | |
1928 | ||
1929 | デフォルトは、デバッグモードを無効にします。 | |
1930 | ||
1931 | 1182 | =back |
1932 | 1183 | |
1933 | 1184 | =head1 WARNING |
1934 | 1185 | |
1935 | 1186 | (警告) |
1936 | 1187 | |
1937 | 1188 | =begin original |
1938 | 1189 | |
1939 | 1190 | For maximum security, endeavour always to avoid ever looking at, |
1940 | 1191 | touching, or even imputing the existence of the filename. You do not |
1941 | 1192 | know that that filename is connected to the same file as the handle |
1942 | 1193 | you have, and attempts to check this can only trigger more race |
1943 | 1194 | conditions. It's far more secure to use the filehandle alone and |
1944 | 1195 | dispense with the filename altogether. |
1945 | 1196 | |
1946 | 1197 | =end original |
1947 | 1198 | |
1948 | 1199 | 最高のセキュリティのためには、あるファイルの存在を、調べたり、 |
1949 | 1200 | 作成したり、仮定したりすることを避けるように努力して下さい。 |
1950 | 1201 | そのファイル名があなたの持っているハンドルと同じファイルに |
1951 | 1202 | 接続されているかどうかはわかりませんし、 |
1952 | 1203 | それを調べようとすることはより多くの競合状態を引き起こすだけです。 |
1953 | 1204 | ファイルハンドルだけを使い、ファイル名と切り離す方があるかに安全です。 |
1954 | 1205 | |
1955 | 1206 | =begin original |
1956 | 1207 | |
1957 | 1208 | If you need to pass the handle to something that expects a filename |
1958 | 1209 | then, on a unix system, use C<"/dev/fd/" . fileno($fh)> for arbitrary |
1959 | 1210 | programs, or more generally C<< "+<=&" . fileno($fh) >> for Perl |
1960 | 1211 | programs. You will have to clear the close-on-exec bit on that file |
1961 | 1212 | descriptor before passing it to another process. |
1962 | 1213 | |
1963 | 1214 | =end original |
1964 | 1215 | |
1965 | 1216 | ファイルネームを期待するものにハンドルを渡す必要があるなら、 |
1966 | 1217 | unix システムでは、任意のプログラムに対して C<"/dev/fd/" . fileno($fh)> を |
1967 | 1218 | 使ってください; |
1968 | 1219 | または、より一般的に Perl のプログラムのために |
1969 | 1220 | C<< "+<=&" . fileno($fh) >> を使って下さい。 |
1970 | 1221 | 他のプロセスにそれを渡す前にファイル記述子で close-on-exec ビット |
1971 | 1222 | をクリアする必要があるでそしょう。 |
1972 | 1223 | |
1973 | 1224 | use Fcntl qw/F_SETFD F_GETFD/; |
1974 | 1225 | fcntl($tmpfh, F_SETFD, 0) |
1975 | 1226 | or die "Can't clear close-on-exec flag on temp fh: $!\n"; |
1976 | 1227 | |
1977 | 1228 | =head2 Temporary files and NFS |
1978 | 1229 | |
1979 | (一時ファイルと | |
1230 | (一時ファイルとNFS) | |
1980 | 1231 | |
1981 | 1232 | =begin original |
1982 | 1233 | |
1983 | 1234 | Some problems are associated with using temporary files that reside |
1984 | 1235 | on NFS file systems and it is recommended that a local filesystem |
1985 | 1236 | is used whenever possible. Some of the security tests will most probably |
1986 | 1237 | fail when the temp file is not local. Additionally, be aware that |
1987 | 1238 | the performance of I/O operations over NFS will not be as good as for |
1988 | 1239 | a local disk. |
1989 | 1240 | |
1990 | 1241 | =end original |
1991 | 1242 | |
1992 | 1243 | NFS ファイルシステムにある一時ファイルを使うことに関してはいくつかの |
1993 | 1244 | 問題があり、出来る限りローカルのファイルシステムを使うことが |
1994 | 1245 | 推奨されます。 |
1995 | 1246 | いくつかのセキュリティテストは、一時ファイルがローカルにない場合、 |
1996 | 1247 | ほとんどたいてい失敗するでしょう。 |
1997 | 1248 | 更に、NFS 越しの I/O 操作はローカルディスクほど良くないことに |
1998 | 1249 | 気をつけて下さい。 |
1999 | 1250 | |
2000 | =head2 Forking | |
2001 | ||
2002 | (fork する) | |
2003 | ||
2004 | =begin original | |
2005 | ||
2006 | In some cases files created by File::Temp are removed from within an | |
2007 | END block. Since END blocks are triggered when a child process exits | |
2008 | (unless C<POSIX::_exit()> is used by the child) File::Temp takes care | |
2009 | to only remove those temp files created by a particular process ID. This | |
2010 | means that a child will not attempt to remove temp files created by the | |
2011 | parent process. | |
2012 | ||
2013 | =end original | |
2014 | ||
2015 | 場合によっては File::Temp によって作られたファイルは END ブロックの中で | |
2016 | 削除されます。 | |
2017 | (C<POSIX::_exit()> が子で使われていない限り) 子プロセスの終了時に | |
2018 | END ブロックが実行されるので、 | |
2019 | File::Temp は特定のプロセス ID で作成された一時ファイルのみを削除するように | |
2020 | 注意を払います。 | |
2021 | つまり、子プロセスは親プロセスによって作られた一時ファイルを | |
2022 | 削除しようとしません。 | |
2023 | ||
2024 | =begin original | |
2025 | ||
2026 | If you are forking many processes in parallel that are all creating | |
2027 | temporary files, you may need to reset the random number seed using | |
2028 | srand(EXPR) in each child else all the children will attempt to walk | |
2029 | through the same set of random file names and may well cause | |
2030 | themselves to give up if they exceed the number of retry attempts. | |
2031 | ||
2032 | =end original | |
2033 | ||
2034 | もしそれぞれが一時ファイルを作る多くのプロセスを平行に fork するなら、 | |
2035 | それぞれの子で srand(EXPR) を使うことで乱数の種をリセットする必要が | |
2036 | あるかもしれません; さもなければ全ての子が同じランダムファイル名の | |
2037 | 集合を通過しようとして、再試行回数を超えると諦めてしまうかもしれません。 | |
2038 | ||
2039 | =head2 Directory removal | |
2040 | ||
2041 | (ディレクトリの削除) | |
2042 | ||
2043 | =begin original | |
2044 | ||
2045 | Note that if you have chdir'ed into the temporary directory and it is | |
2046 | subsequently cleaned up (either in the END block or as part of object | |
2047 | destruction), then you will get a warning from File::Path::rmtree(). | |
2048 | ||
2049 | =end original | |
2050 | ||
2051 | 一時ディレクトリに chdir して、その後(END ブロックやオブジェクト破壊の | |
2052 | 一部として)それを片付けると、 | |
2053 | File::Path::rmtree() から警告が出ることに注意してください。 | |
2054 | ||
2055 | =head2 BINMODE | |
2056 | ||
2057 | =begin original | |
2058 | ||
2059 | The file returned by File::Temp will have been opened in binary mode | |
2060 | if such a mode is available. If that is not correct, use the C<binmode()> | |
2061 | function to change the mode of the filehandle. | |
2062 | ||
2063 | =end original | |
2064 | ||
2065 | File::Temp から返されたファイルは、(モードがある場合は)バイナリモードで | |
2066 | 開かれます。 | |
2067 | これが正しくない場合、ファイルハンドルのモードを変更するために | |
2068 | C<binmode()> 関数を使ってください。 | |
2069 | ||
2070 | =begin original | |
2071 | ||
2072 | Note that you can modify the encoding of a file opened by File::Temp | |
2073 | also by using C<binmode()>. | |
2074 | ||
2075 | =end original | |
2076 | ||
2077 | C<binmode()> を使うことで、File::Temp によって開かれたファイルの | |
2078 | エンコーディングを変更できることに注意してください。 | |
2079 | ||
2080 | 1251 | =head1 HISTORY |
2081 | 1252 | |
2082 | ( | |
1253 | (経緯) | |
2083 | 1254 | |
2084 | 1255 | =begin original |
2085 | 1256 | |
2086 | 1257 | Originally began life in May 1999 as an XS interface to the system |
2087 | 1258 | mkstemp() function. In March 2000, the OpenBSD mkstemp() code was |
2088 | 1259 | translated to Perl for total control of the code's |
2089 | 1260 | security checking, to ensure the presence of the function regardless of |
2090 | operating system and to help with portability. | |
1261 | operating system and to help with portability. | |
2091 | as a standard part of perl from v5.6.1. | |
2092 | 1262 | |
2093 | 1263 | =end original |
2094 | 1264 | |
2095 | 1265 | もともとは、1999 年の 5 月にシステムの mkstemp() 関数への |
2096 | 1266 | XS インターフェースとして生まれました。 |
2097 | 1267 | 2000 年 5 月に、コードのセキュリティチェックを完全に制御するために、 |
2098 | 1268 | OpenBSD の mkstemp() コードが Perl に移植されました; |
2099 | 1269 | オペレーティングシステムに依存しない関数の存在を保証することになり、 |
2100 | 1270 | 移植性を助けることになりました。 |
2101 | このモジュールは v5.6.1 から perl の標準として配布されています。 | |
2102 | 1271 | |
2103 | 1272 | =head1 SEE ALSO |
2104 | 1273 | |
2105 | 1274 | L<POSIX/tmpnam>, L<POSIX/tmpfile>, L<File::Spec>, L<File::Path> |
2106 | 1275 | |
2107 | 1276 | =begin original |
2108 | 1277 | |
2109 | See L<IO::File> and L<File::MkTemp> | |
1278 | See L<IO::File> and L<File::MkTemp> for different implementations of | |
2110 | ||
1279 | temporary file handling. | |
2111 | 1280 | |
2112 | 1281 | =end original |
2113 | 1282 | |
2114 | 一時ファイルを扱う異なった実装については L<IO::File> | |
1283 | 一時ファイルを扱う異なった実装については L<IO::File> と L<File::MkTemp> を | |
2115 | ||
1284 | 参照してください。 | |
2116 | 1285 | |
2117 | =begin original | |
2118 | ||
2119 | See L<File::Tempdir> for an alternative object-oriented wrapper for | |
2120 | the C<tempdir> function. | |
2121 | ||
2122 | =end original | |
2123 | ||
2124 | もう一つの C<tempdir> 関数のオブジェクト指向のラッパーについては | |
2125 | L<File::Tempdir> を参照してください。 | |
2126 | ||
2127 | 1286 | =head1 AUTHOR |
2128 | 1287 | |
2129 | Tim Jenness E<lt>tjenness@c | |
1288 | Tim Jenness E<lt>t.jenness@jach.hawaii.eduE<gt> | |
2130 | 1289 | |
2131 | Copyright (C) | |
1290 | Copyright (C) 1999-2001 Tim Jenness and the UK Particle Physics and | |
2132 | Copyright (C) 1999-2007 Tim Jenness and the UK Particle Physics and | |
2133 | 1291 | Astronomy Research Council. All Rights Reserved. This program is free |
2134 | 1292 | software; you can redistribute it and/or modify it under the same |
2135 | 1293 | terms as Perl itself. |
2136 | 1294 | |
2137 | Original Perl implementation loosely based on the OpenBSD C code for | |
1295 | Original Perl implementation loosely based on the OpenBSD C code for | |
2138 | 1296 | mkstemp(). Thanks to Tom Christiansen for suggesting that this module |
2139 | 1297 | should be written and providing ideas for code improvements and |
2140 | 1298 | security enhancements. |
2141 | ||
2142 | =cut | |
2143 | 1299 | |
2144 | 1300 | =begin meta |
2145 | 1301 | |
2146 | 1302 | Update: SHIRAKATA Kentaro <argrath@ub32.org> (0.12-) |
2147 | 1303 | Status: completed |
2148 | 1304 | |
2149 | 1305 | =end meta |