Secure temporary file: Difference between revisions
Content added Content deleted
Line 438: | Line 438: | ||
# specify a prefix, a suffix, or both for the filename |
# specify a prefix, a suffix, or both for the filename |
||
my ($filename5,$filehandle5) = tempfile(:prefix('foo'), :suffix(".txt"));</lang> |
my ($filename5,$filehandle5) = tempfile(:prefix('foo'), :suffix(".txt"));</lang> |
||
=={{header|Phix}}== |
|||
The temp_file() function (see builtins/pfile.e) can be used for this: |
|||
<lang Phix>pp(temp_file()) |
|||
{integer fn, string name} = temp_file("myapp/tmp","data","log","wb") |
|||
pp({fn,name}) -- (obviously omit name if not needed..) |
|||
close(fn) |
|||
{} = delete_file(name)</lang> |
|||
{{out}} |
|||
<pre> |
|||
`C:\Users\Pete\AppData\Local\Temp\419750.tmp` |
|||
{3, `C:\Program Files (x86)\Phix\myapp\tmp\data408865.log`} |
|||
</pre> |
|||
If you don't provide an open mode (one of "w", "wb", "a", or "ab") then there is a 1-in-a-million |
|||
chance someone else will beat you to the punch; if you do provide one, it will open/loop for you. |
|||
=={{header|PHP}}== |
=={{header|PHP}}== |