June 2018 Update
This commit is contained in:
parent
ba8067c3b7
commit
22f33d4004
5278 changed files with 84726 additions and 14379 deletions
20
Task/Secure-temporary-file/Perl-6/secure-temporary-file.pl6
Normal file
20
Task/Secure-temporary-file/Perl-6/secure-temporary-file.pl6
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
use File::Temp;
|
||||
|
||||
# Generate a temp file in a temp dir
|
||||
my ($filename0,$filehandle0) = tempfile;
|
||||
|
||||
# specify a template for the filename
|
||||
# * are replaced with random characters
|
||||
my ($filename1,$filehandle1) = tempfile("******");
|
||||
|
||||
# Automatically unlink files at DESTROY (this is the default)
|
||||
my ($filename2,$filehandle2) = tempfile("******", :unlink);
|
||||
|
||||
# Specify the directory where the tempfile will be created
|
||||
my ($filename3,$filehandle3) = tempfile(:tempdir("/path/to/my/dir"));
|
||||
|
||||
# don't unlink this one
|
||||
my ($filename4,$filehandle4) = tempfile(:tempdir('.'), :!unlink);
|
||||
|
||||
# specify a prefix, a suffix, or both for the filename
|
||||
my ($filename5,$filehandle5) = tempfile(:prefix('foo'), :suffix(".txt"));
|
||||
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
: (let F (tmp "foo")
|
||||
(ctl F # Get exclusive lock
|
||||
(let N (in F (read)) # Atomic increment
|
||||
(out F (println (inc N))) ) ) )
|
||||
(in F
|
||||
(let N (read) # Atomic increment
|
||||
(out F (println (inc N))) ) ) ) )
|
||||
-> 124
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue