Secure temporary file: Difference between revisions

Content added Content deleted
mNo edit summary
Line 333: Line 333:
<lang Mathematica>tmp = OpenWrite[]
<lang Mathematica>tmp = OpenWrite[]
Close[tmp]</lang>
Close[tmp]</lang>

=={{header|Nanoquery}}==
<lang Nanoquery>import Nanoquery.IO

def guaranteedTempFile()
// create a file object to generate temp file names
$namegen = new(File)

// generate a temp filename
$tempname = $namegen.tempFileName()
// file names are generated with uuids so they shouldn't repeat
// in the case that they do, generate new ones until the generated
// filename is unique
$tempfile = new(File, $tempname)
while ($tempfile.exists())
$tempname = $namegen.tempFileName()
$tempfile = new(File, $tempname)
end

// create the file and lock it from writing
$tempfile.create()
lock $tempfile.fullPath()

// return the file reference
return $tempfile
end</lang>


=={{header|NetRexx}}==
=={{header|NetRexx}}==