unlink0#
Remove a temporary file while its filehandle is still open.
Synopsis#
unlink0($fh, $path) or die "unlink0: $!";
What you get back#
Integer 1 on success. The directory entry is removed; reads
and writes on $fh continue to work, and the blocks are
released when $fh is finally closed.
Examples#
use File::Temp qw/ tempfile unlink0 /;
my ($fh, $path) = tempfile();
unlink0($fh, $path);
## $path is gone, but $fh is still usable
Edge cases#
If
$File::Temp::KEEP_ALLis true the function returns1without unlinking.Fewer than two arguments: no-op, returns
1.
Differences from upstream#
Upstream performs a full
stat/fstatcomparison before unlinking to detect races and symlink tricks. This implementation unlinks by path without that check. Callers who need the stat-equality guarantee should validate the handle themselves. Covered byt/81-xs-native/File-Temp/*.t.
See also#
unlink1— close-then-unlink variant.cmpstat— the stat comparison used by upstreamunlink0.tempfile— uses this internally in scalar context.