Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit b5eb07e

Browse filesBrowse files
committed
Use native methods to open input in TestLib::slurp_file on Windows.
This is a backport of commits 114541d and 6f59826f0 to the remaining live branches.
1 parent f10da1e commit b5eb07e
Copy full SHA for b5eb07e

File tree

Expand file treeCollapse file tree

1 file changed

+23
-4
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+23
-4
lines changed

‎src/test/perl/TestLib.pm

Copy file name to clipboardExpand all lines: src/test/perl/TestLib.pm
+23-4Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,11 @@ BEGIN
6363

6464
# Must be set early
6565
$windows_os = $Config{osname} eq 'MSWin32' || $Config{osname} eq 'msys';
66+
if ($windows_os)
67+
{
68+
require Win32API::File;
69+
Win32API::File->import(qw(createFile OsFHandleOpen CloseHandle));
70+
}
6671
}
6772

6873
INIT
@@ -212,10 +217,24 @@ sub slurp_file
212217
{
213218
my ($filename) = @_;
214219
local $/;
215-
open(my $in, '<', $filename)
216-
or die "could not read \"$filename\": $!";
217-
my $contents = <$in>;
218-
close $in;
220+
my $contents;
221+
if ($Config{osname} ne 'MSWin32')
222+
{
223+
open(my $in, '<', $filename)
224+
or die "could not read \"$filename\": $!";
225+
$contents = <$in>;
226+
close $in;
227+
}
228+
else
229+
{
230+
my $fHandle = createFile($filename, "r", "rwd")
231+
or die "could not open \"$filename\": $^E";
232+
OsFHandleOpen(my $fh = IO::Handle->new(), $fHandle, 'r')
233+
or die "could not read \"$filename\": $^E\n";
234+
$contents = <$fh>;
235+
CloseHandle($fHandle)
236+
or die "could not close \"$filename\": $^E\n";
237+
}
219238
$contents =~ s/\r\n/\n/g if $Config{osname} eq 'msys';
220239
return $contents;
221240
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.