From: Steve Peters Date: Tue, 23 Jan 2007 15:02:56 +0000 (+0000) Subject: Upgrade to File-Temp-0.18. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=0dae80a28977a140e2612895990f004c2224ae10;p=p5sagit%2Fp5-mst-13.2.git Upgrade to File-Temp-0.18. p4raw-id: //depot/perl@29935 --- diff --git a/MANIFEST b/MANIFEST index 12c1351..a55fdc9 100644 --- a/MANIFEST +++ b/MANIFEST @@ -1748,6 +1748,7 @@ lib/File/Spec/Win32.pm portable operations on Win32 and NetWare file names lib/File/stat.pm By-name interface to Perl's builtin stat lib/File/stat.t See if File::stat works lib/File/Temp.pm create safe temporary files and file handles +lib/File/Temp/t/cmp.t See if File::Temp works lib/File/Temp/t/mktemp.t See if File::Temp works lib/File/Temp/t/object.t See if File::Temp works lib/File/Temp/t/posix.t See if File::Temp works diff --git a/lib/File/Temp.pm b/lib/File/Temp.pm index fa499c0..b933963 100644 --- a/lib/File/Temp.pm +++ b/lib/File/Temp.pm @@ -140,6 +140,7 @@ use Carp; use File::Spec 0.8; use File::Path qw/ rmtree /; use Fcntl 1.03; +use IO::Seekable; # For SEEK_* use Errno; require VMS::Stdio if $^O eq 'VMS'; @@ -155,8 +156,7 @@ require Symbol if $] < 5.006; ### For the OO interface use base qw/ IO::Handle IO::Seekable /; -use overload '""' => "STRINGIFY"; - +use overload '""' => "STRINGIFY", fallback => 1; # use 'our' on v5.6.0 use vars qw($VERSION @EXPORT_OK %EXPORT_TAGS $DEBUG $KEEP_ALL); @@ -199,7 +199,7 @@ Exporter::export_tags('POSIX','mktemp','seekable'); # Version number -$VERSION = '0.17'; +$VERSION = '0.18'; # This is a list of characters that can be used in random filenames @@ -483,12 +483,6 @@ sub _gettemp { # but may have O_NOINHERIT. This may or may not be in Fcntl. local $^F = 2; - # Store callers umask - my $umask = umask(); - - # Set a known umask - umask(066); - # Attempt to open the file my $open_success = undef; if ( $^O eq 'VMS' and $options{"unlink_on_close"} && !$KEEP_ALL) { @@ -503,15 +497,13 @@ sub _gettemp { } if ( $open_success ) { - # Reset umask - umask($umask) if defined $umask; + # in case of odd umask force rw + chmod(0600, $path); # Opened successfully - return file handle and name return ($fh, $path); } else { - # Reset umask - umask($umask) if defined $umask; # Error opening file - abort with error # if the reason was anything but EEXIST @@ -525,24 +517,14 @@ sub _gettemp { } } elsif ($options{"mkdir"}) { - # Store callers umask - my $umask = umask(); - - # Set a known umask - umask(066); - # Open the temp directory if (mkdir( $path, 0700)) { - # created okay - # Reset umask - umask($umask) if defined $umask; + # in case of odd umask + chmod(0700, $path); return undef, $path; } else { - # Reset umask - umask($umask) if defined $umask; - # Abort with error if the reason for failure was anything # except EEXIST unless ($!{EEXIST}) { @@ -655,10 +637,7 @@ sub _replace_XX { # force a file to be readonly when written to certain temp locations sub _force_writable { my $file = shift; - my $umask = umask(); - umask(066); chmod 0600, $file; - umask($umask) if defined $umask; } @@ -985,8 +964,9 @@ object is no longer required. Note that there is no method to obtain the filehandle from the C object. The object itself acts as a filehandle. Also, the object is configured such that it stringifies to the name of the -temporary file. The object isa C and isa C -so all those methods are available. +temporary file, and can be compared to a filename directly. The object +isa C and isa C so all those methods are +available. =over 4 @@ -2273,14 +2253,14 @@ as a standard part of perl from v5.6.1. L, L, L, L -See L and L, L for +See L and L, L for different implementations of temporary file handling. =head1 AUTHOR Tim Jenness Etjenness@cpan.orgE -Copyright (C) 1999-2006 Tim Jenness and the UK Particle Physics and +Copyright (C) 1999-2007 Tim Jenness and the UK Particle Physics and Astronomy Research Council. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. diff --git a/lib/File/Temp/t/cmp.t b/lib/File/Temp/t/cmp.t new file mode 100644 index 0000000..db94e44 --- /dev/null +++ b/lib/File/Temp/t/cmp.t @@ -0,0 +1,11 @@ +#!perl -w +# Test overloading + +use Test::More tests => 3; +use strict; + +BEGIN {use_ok( "File::Temp" ); } + +my $fh = new File::Temp(); +ok( "$fh" ne "foo", "compare stringified object with string"); +ok( $fh ne "foo", "compare object with string"); \ No newline at end of file