Annotation of embedaddon/php/ext/standard/tests/file/fopen_variation11-win32.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test fopen() function : variation: interesting paths, use include path = true
3: --CREDITS--
4: Dave Kelsey <d_kelsey@uk.ibm.com>
5: --SKIPIF--
6: <?php
7: if(substr(PHP_OS, 0, 3) != "WIN")
8: die("skip Run only on Windows");
9: if (!is_writable('c:\\fopen_variation10.tmp')) {
10: die('skip. C:\\ not writable.');
11: }
12:
13: ?>
14: --FILE--
15: <?php
16: /* Prototype : resource fopen(string filename, string mode [, bool use_include_path [, resource context]])
17: * Description: Open a file or a URL and return a file pointer
18: * Source code: ext/standard/file.c
19: * Alias to functions:
20: */
21:
22: echo "*** Testing fopen() : variation ***\n";
23:
24: // fopen with interesting windows paths.
25: $testdir = dirname(__FILE__).'/fopen11.tmpDir';
26: $rootdir = 'fopen11.tmpdirTwo';
27: mkdir($testdir);
28: mkdir('c:\\'.$rootdir);
29:
30: $unixifiedDir = '/'.substr(str_replace('\\','/',$testdir),3);
31:
32: $paths = array('c:\\',
33: 'c:',
34: 'c',
35: '\\',
36: '/',
37: 'c:'.$rootdir,
38: 'c:adir',
39: 'c:\\/',
40: 'c:\\'.$rootdir.'\\/',
41: 'c:\\'.$rootdir.'\\',
42: 'c:\\'.$rootdir.'/',
43: $unixifiedDir,
44: '/sortout');
45:
46: $file = "fopen_variation11.tmp";
47: $firstfile = 'c:\\'.$rootdir.'\\'.$file;
48: $secondfile = $testdir.'\\'.$file;
49: $thirdfile = 'c:\\'.$file;
50:
51: $h = fopen($firstfile, 'w');
52: fwrite($h, "file in $rootdir");
53: fclose($h);
54:
55: $h = fopen($secondfile, 'w');
56: fwrite($h, "file in fopen11.tmpDir");
57: fclose($h);
58:
59: $h = fopen($thirdfile, 'w');
60: fwrite($h, "file in root");
61: fclose($h);
62:
63: foreach($paths as $path) {
64: echo "\n--$path--\n";
65: $toFind = $path.'\\'.$file;
66: $h = fopen($toFind, 'r', true);
67: if ($h === false) {
68: echo "file not opened for read\n";
69: }
70: else {
71: fpassthru($h);
72: echo "\n";
73: }
74: fclose($h);
75: };
76:
77: unlink($firstfile);
78: unlink($secondfile);
79: unlink($thirdfile);
80: rmdir($testdir);
81: rmdir('c:\\'.$rootdir);
82:
83: ?>
84: ===DONE===
85: --EXPECTF--
86: *** Testing fopen() : variation ***
87:
88: --c:\--
89: file in root
90:
91: --c:--
92: file in root
93:
94: --c--
95:
96: Warning: fopen(c\fopen_variation11.tmp): failed to open stream: No such file or directory in %s on line %d
97: file not opened for read
98:
99: Warning: fclose() expects parameter 1 to be resource, boolean given in %s on line %d
100:
101: --\--
102:
103: Warning: fopen(\\FOPEN_VARIATION11.TMP): failed to open stream: Invalid argument in %s on line %d
104: file not opened for read
105:
106: Warning: fclose() expects parameter 1 to be resource, boolean given in %s on line %d
107:
108: --/--
109:
110: Warning: fopen(\\FOPEN_VARIATION11.TMP): failed to open stream: Invalid argument in %s on line %d
111: file not opened for read
112:
113: Warning: fclose() expects parameter 1 to be resource, boolean given in %s on line %d
114:
115: --c:fopen11.tmpdirTwo--
116: file in fopen11.tmpdirTwo
117:
118: --c:adir--
119:
120: Warning: fopen(c:adir\fopen_variation11.tmp): failed to open stream: No such file or directory in %s on line %d
121: file not opened for read
122:
123: Warning: fclose() expects parameter 1 to be resource, boolean given in %s on line %d
124:
125: --c:\/--
126: file in root
127:
128: --c:\fopen11.tmpdirTwo\/--
129: file in fopen11.tmpdirTwo
130:
131: --c:\fopen11.tmpdirTwo\--
132: file in fopen11.tmpdirTwo
133:
134: --c:\fopen11.tmpdirTwo/--
135: file in fopen11.tmpdirTwo
136:
137: --%s/fopen11.tmpDir--
138: file in fopen11.tmpDir
139:
140: --/sortout--
141:
142: Warning: fopen(/sortout\fopen_variation11.tmp): failed to open stream: No such file or directory in %s on line %d
143: file not opened for read
144:
145: Warning: fclose() expects parameter 1 to be resource, boolean given in %s on line %d
146: ===DONE===
147:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>