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:\\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 22echo "*** Testing fopen() : variation ***\n"; 23 24// fopen with interesting windows paths. 25$testdir = dirname(__FILE__).'/fopen11.tmpDir'; 26$rootdir = 'fopen11.tmpdirTwo'; 27mkdir($testdir); 28mkdir('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'); 52fwrite($h, "file in $rootdir"); 53fclose($h); 54 55$h = fopen($secondfile, 'w'); 56fwrite($h, "file in fopen11.tmpDir"); 57fclose($h); 58 59$h = fopen($thirdfile, 'w'); 60fwrite($h, "file in root"); 61fclose($h); 62 63foreach($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 77unlink($firstfile); 78unlink($secondfile); 79unlink($thirdfile); 80rmdir($testdir); 81rmdir('c:\\'.$rootdir); 82 83?> 84===DONE=== 85--EXPECTF-- 86*** Testing fopen() : variation *** 87 88--c:\-- 89file in root 90 91--c:-- 92file in root 93 94--c-- 95 96Warning: fopen(c\fopen_variation11.tmp): failed to open stream: No such file or directory in %s on line %d 97file not opened for read 98 99Warning: fclose() expects parameter 1 to be resource, boolean given in %s on line %d 100 101--\-- 102 103Warning: fopen(\\FOPEN_VARIATION11.TMP): failed to open stream: Invalid argument in %s on line %d 104file not opened for read 105 106Warning: fclose() expects parameter 1 to be resource, boolean given in %s on line %d 107 108--/-- 109 110Warning: fopen(\\FOPEN_VARIATION11.TMP): failed to open stream: Invalid argument in %s on line %d 111file not opened for read 112 113Warning: fclose() expects parameter 1 to be resource, boolean given in %s on line %d 114 115--c:fopen11.tmpdirTwo-- 116file in fopen11.tmpdirTwo 117 118--c:adir-- 119 120Warning: fopen(c:adir\fopen_variation11.tmp): failed to open stream: No such file or directory in %s on line %d 121file not opened for read 122 123Warning: fclose() expects parameter 1 to be resource, boolean given in %s on line %d 124 125--c:\/-- 126file in root 127 128--c:\fopen11.tmpdirTwo\/-- 129file in fopen11.tmpdirTwo 130 131--c:\fopen11.tmpdirTwo\-- 132file in fopen11.tmpdirTwo 133 134--c:\fopen11.tmpdirTwo/-- 135file in fopen11.tmpdirTwo 136 137--%s/fopen11.tmpDir-- 138file in fopen11.tmpDir 139 140--/sortout-- 141 142Warning: fopen(/sortout\fopen_variation11.tmp): failed to open stream: No such file or directory in %s on line %d 143file not opened for read 144 145Warning: fclose() expects parameter 1 to be resource, boolean given in %s on line %d 146===DONE=== 147