1--TEST--
2Test fopen() function : variation: interesting paths, use include path = true
3--CREDITS--
4Dave Kelsey <d_kelsey@uk.ibm.com>
5--SKIPIF--
6<?php
7if(substr(PHP_OS, 0, 3) != "WIN")
8  die("skip Run only on Windows");
9if (!is_writable('c:\\')) {
10    die('skip. C:\\ not writable.');
11}
12
13?>
14--FILE--
15<?php
16echo "*** Testing fopen() : variation ***\n";
17
18// fopen with interesting windows paths.
19$testdir = __DIR__.'/fopen11.tmpDir';
20$rootdir = 'fopen11.tmpdirTwo';
21mkdir($testdir);
22mkdir('c:\\'.$rootdir);
23
24$unixifiedDir = '/'.substr(str_replace('\\','/',$testdir),3);
25
26$paths = array('c:\\',
27               'c:',
28               'c',
29               '\\',
30               '/',
31               'c:'.$rootdir,
32               'c:adir',
33               'c:\\/',
34               'c:\\'.$rootdir.'\\/',
35               'c:\\'.$rootdir.'\\',
36               'c:\\'.$rootdir.'/',
37               $unixifiedDir,
38               '/sortout');
39
40$file = "fopen_variation11.tmp";
41$firstfile = 'c:\\'.$rootdir.'\\'.$file;
42$secondfile = $testdir.'\\'.$file;
43$thirdfile = 'c:\\'.$file;
44
45$h = fopen($firstfile, 'w');
46fwrite($h, "file in $rootdir");
47fclose($h);
48
49$h = fopen($secondfile, 'w');
50fwrite($h, "file in fopen11.tmpDir");
51fclose($h);
52
53$h = fopen($thirdfile, 'w');
54fwrite($h, "file in root");
55fclose($h);
56
57foreach($paths as $path) {
58      echo "\n--$path--\n";
59      $toFind = $path.'\\'.$file;
60         $h = fopen($toFind, 'r', true);
61         if ($h === false) {
62            echo "file not opened for read\n";
63         }
64         else {
65            fpassthru($h);
66            fclose($h);
67            echo "\n";
68         }
69};
70
71unlink($firstfile);
72unlink($secondfile);
73unlink($thirdfile);
74rmdir($testdir);
75rmdir('c:\\'.$rootdir);
76
77?>
78--EXPECTF--
79*** Testing fopen() : variation ***
80
81--c:\--
82file in root
83
84--c:--
85file in root
86
87--c--
88
89Warning: fopen(c\fopen_variation11.tmp): Failed to open stream: No such file or directory in %s on line %d
90file not opened for read
91
92--\--
93
94Warning: fopen(\\FOPEN_VARIATION11.TMP): Failed to open stream: No such file or directory in %s on line %d
95file not opened for read
96
97--/--
98
99Warning: fopen(\\FOPEN_VARIATION11.TMP): Failed to open stream: No such file or directory in %s on line %d
100file not opened for read
101
102--c:fopen11.tmpdirTwo--
103file in fopen11.tmpdirTwo
104
105--c:adir--
106
107Warning: fopen(c:adir\fopen_variation11.tmp): Failed to open stream: No such file or directory in %s on line %d
108file not opened for read
109
110--c:\/--
111file in root
112
113--c:\fopen11.tmpdirTwo\/--
114file in fopen11.tmpdirTwo
115
116--c:\fopen11.tmpdirTwo\--
117file in fopen11.tmpdirTwo
118
119--c:\fopen11.tmpdirTwo/--
120file in fopen11.tmpdirTwo
121
122--%s/fopen11.tmpDir--
123file in fopen11.tmpDir
124
125--/sortout--
126
127Warning: fopen(/sortout\fopen_variation11.tmp): Failed to open stream: No such file or directory in %s on line %d
128file not opened for read
129