iets veiligere creatie van tijdelijke bestanden

This commit is contained in:
Ward Wouts 2013-01-23 10:57:51 +00:00
parent e8c8a098cd
commit df843589c0

View file

@ -3,7 +3,7 @@
# $Id$
#
# Copyright (c) 2001 - 2007 Ward Wouts <ward@wouts.nl>
# Copyright (c) 2001 - 2013 Ward Wouts <ward@wouts.nl>
#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
@ -23,9 +23,10 @@
# Much easier than doing 6000 moves by hand
#
require File::Temp;
use File::Temp qw(tempfile);
use IO::File;
use File::Copy;
use POSIX qw(tmpnam);
use Getopt::Long;
use strict;
use warnings;
@ -77,8 +78,8 @@ sub edit($) {
sub open_temp {
my $target;
my $target_name;
do { $target_name = tmpnam() }
until $target = IO::File->new($target_name, O_RDWR|O_CREAT|O_EXCL);
($target, $target_name) = tempfile( TEMPLATE => 'MVWXXXXXXX', SUFFIX => '.mvwrap');
# Volgende regel werkt niet...
END { if ($opt_e) { unlink($target_name) or die("Couldn't unlink $target_name: $!");} }
foreach (@source) {
print $target "$_\n";