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