From: Jarkko Hietaniemi Date: Thu, 24 Aug 2000 13:49:38 +0000 (+0000) Subject: DOS patches and portability/porting notes, from Tim Jenness. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=e77f578cfdd9ec4b1afe1055f3695060aef2df6c;p=p5sagit%2Fp5-mst-13.2.git DOS patches and portability/porting notes, from Tim Jenness. p4raw-id: //depot/perl@6799 --- diff --git a/lib/File/Temp.pm b/lib/File/Temp.pm index e5b9982..fd84744 100644 --- a/lib/File/Temp.pm +++ b/lib/File/Temp.pm @@ -4,6 +4,40 @@ package File::Temp; File::Temp - return name and handle of a temporary file safely +=begin __INTERNALS + +=head1 PORTABILITY + +This module is designed to be portable across operating systems +and it currently supports Unix, VMS, DOS, OS/2 and Windows. When +porting to a new OS there are generally three main issues +that have to be solved: + +=over 4 + +=item * + +Can the OS unlink an open file? If it can't then the +C<_can_unlink_opened_file> method should be modified. + +=item * + +Are the return values from C reliable? By default all the +return values from C are compared when unlinking a temporary +file using the filename and the handle. Operating systems other than +unix do not always have valid entries in all fields. If C fails +then the C comparison should be modified accordingly. + +=item * + +Security. Systems that can not support a test for the sticky bit +on a directory can not use the MEDIUM and HIGH security tests. +The C<_can_do_level> method should be modified accordingly. + +=back + +=end __INTERNALS + =head1 SYNOPSIS use File::Temp qw/ tempfile tempdir /; @@ -674,7 +708,7 @@ sub _is_verysafe { sub _can_unlink_opened_file { - if ($^O eq 'MSWin32' || $^O eq 'os2' || $^O eq 'VMS') { + if ($^O eq 'MSWin32' || $^O eq 'os2' || $^O eq 'VMS' || $^O eq 'dos') { return 0; } else { return 1; @@ -1492,6 +1526,8 @@ sub unlink0 { @okstat = (1,2,3,4,5,7,8,9,10); } elsif ($^O eq 'os2') { @okstat = (0, 2..$#fh); + } elsif ($^O eq 'dos') { + @okstat = (2,3,4,5,7,8,9,10); } elsif ($^O eq 'VMS') { # device and file ID are sufficient @okstat = (0, 1); } @@ -1693,7 +1729,7 @@ descriptor before passing it to another process. =head1 HISTORY Originally began life in May 1999 as an XS interface to the system -mkstemp() function. In March 2000, the mkstemp() code was +mkstemp() function. In March 2000, the OpenBSD mkstemp() code was translated to Perl for total control of the code's security checking, to ensure the presence of the function regardless of operating system and to help with portability.