unlink0#

Remove a temporary file while its filehandle is still open.

Σύνοψη#

unlink0($fh, $path) or die "unlink0: $!";

Τι επιστρέφεται#

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.

Παραδείγματα#

use File::Temp qw/ tempfile unlink0 /;
my ($fh, $path) = tempfile();
unlink0($fh, $path);

## $path is gone, but $fh is still usable

Οριακές περιπτώσεις#

  • If $File::Temp::KEEP_ALL is true the function returns 1 without unlinking.

  • Fewer than two arguments: no-op, returns 1.

Διαφορές από το upstream#

  • Upstream performs a full stat/fstat comparison 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 by t/81-xs-native/File-Temp/*.t.

Δείτε επίσης#

  • unlink1 - close-then-unlink variant.

  • cmpstat - the stat comparison used by upstream unlink0.

  • tempfile - uses this internally in scalar context.