File tree Expand file tree Collapse file tree 1 file changed +29
-5
lines changed Expand file tree Collapse file tree 1 file changed +29
-5
lines changed Original file line number Diff line number Diff line change @@ -44,7 +44,17 @@ use SimpleTee;
44
44
45
45
use Test::More;
46
46
47
- our $windows_os = $Config {osname } eq ' MSWin32' || $Config {osname } eq ' msys' ;
47
+ our $windows_os ;
48
+
49
+ BEGIN
50
+ {
51
+ $windows_os = $Config {osname } eq ' MSWin32' || $Config {osname } eq ' msys' ;
52
+ if ($windows_os )
53
+ {
54
+ require Win32API::File;
55
+ Win32API::File-> import (qw( createFile OsFHandleOpen CloseHandle) );
56
+ }
57
+ }
48
58
49
59
# Open log file. For each test, the log file name uses the name of the
50
60
# file launching this module, without the .pl suffix.
@@ -277,10 +287,24 @@ sub slurp_file
277
287
{
278
288
my ($filename ) = @_ ;
279
289
local $/ ;
280
- open (my $in , ' <' , $filename )
281
- or die " could not read \" $filename \" : $! " ;
282
- my $contents = <$in >;
283
- close $in ;
290
+ my $contents ;
291
+ if ($Config {osname } ne ' MSWin32' )
292
+ {
293
+ open (my $in , ' <' , $filename )
294
+ or die " could not read \" $filename \" : $! " ;
295
+ $contents = <$in >;
296
+ close $in ;
297
+ }
298
+ else
299
+ {
300
+ my $fHandle = createFile($filename , " r" , " rwd" )
301
+ or die " could not open \" $filename \" : $^E" ;
302
+ OsFHandleOpen(my $fh = IO::Handle-> new(), $fHandle , ' r' )
303
+ or die " could not read \" $filename \" : $^E\n " ;
304
+ $contents = <$fh >;
305
+ CloseHandle($fHandle )
306
+ or die " could not close \" $filename \" : $^E\n " ;
307
+ }
284
308
$contents =~ s /\r\n / \n / g if $Config {osname } eq ' msys' ;
285
309
return $contents ;
286
310
}
You can’t perform that action at this time.
0 commit comments