# Attempt to open the file
my $open_success = undef;
- if ( $^O eq 'VMS' ) { # make it auto delete on close
+ if ( $^O eq 'VMS' and $options{"unlink_on_close"} ) {
+ # make it auto delete on close by setting FAB$V_DLT bit
$fh = VMS::Stdio::vmssysopen($path, $OPENFLAGS, 0600, 'fop=dlt');
$open_success = $fh;
} else {
# probably a better way to do this
close($file->[0]); # file handle is [0]
- # On VMS, the file will be automatically deleted on close,
- # so we are through with the file already.
- next if $^O eq 'VMS';
-
if (-f $file->[1]) { # file name is [1]
unlink $file->[1] or warn "Error removing ".$file->[1];
}
# Default options
my %options = (
"DIR" => undef, # Directory prefix
- "SUFFIX" => '', # Template suffix
- "UNLINK" => 0, # Unlink file on exit
- "OPEN" => 1, # Do not open file
+ "SUFFIX" => '', # Template suffix
+ "UNLINK" => 0, # Do not unlink file on exit
+ "OPEN" => 1, # Open file
);
# Check to see whether we have an odd or even number of arguments
}
+ if ($options{"DIR"} and $^O eq 'VMS') {
+
+ # on VMS turn []foo into [.foo] for concatenation
+ $options{"DIR"} = VMS::Filespec::vmspath($options{"DIR"});
+ }
+
# Construct the template
# Have a choice of trying to work around the mkstemp/mktemp/tmpnam etc
unless (($fh, $path) = _gettemp($template,
"open" => $options{'OPEN'},
"mkdir"=> 0 ,
+ "unlink_on_close" => $options{'UNLINK'},
"suffixlen" => length($options{'SUFFIX'}),
) );