2 # Test retrieving a file with a 'file://' URL,
11 # First locate some suitable tmp-dir. We need an absolute path.
13 for ("/tmp/", "/var/tmp", "/usr/tmp", "/local/tmp") {
14 if (open(TEST, ">$_/test-$$")) {
21 $TMPDIR ||= $ENV{TEMP} if $^O eq 'MSWin32';
32 require LWP::Protocol::file;
34 my $orig = "$TMPDIR/lwp-orig-$$"; # local file
35 my $copy = "$TMPDIR/lwp-copy-$$"; # downloaded copy
37 # First we create the original
38 open(OUT, ">$orig") or die "Cannot open $orig: $!";
41 print OUT "This is line $_ of $orig\n";
46 # Then we make a test using getprint(), so we need to capture stdout
47 open (OUT, ">$copy") or die "Cannot open $copy: $!";
51 getprint("file://localhost" . ($orig =~ m|^/| ? $orig : "/$orig"));
56 # read and compare the files
57 open(IN, $orig) or die "Cannot open '$orig': $!";
61 open(IN, $copy) or die "Cannot open '$copy': $!";
68 if ($origtext eq $copytext) {
76 # Test getstore() function
78 getstore("file:$orig", $copy);
80 # Take a look at the new copy
81 open(IN, $copy) or die "Cannot open '$copy': $!";
89 if ($origtext eq $copytext) {