1--TEST-- 2Test rmdir() function : variation: various valid and invalid paths 3--CREDITS-- 4Dave Kelsey <d_kelsey@uk.ibm.com> 5--SKIPIF-- 6<?php 7if(substr(PHP_OS, 0, 3) != "WIN") 8 die("skip Only valid for Windows"); 9?> 10--FILE-- 11<?php 12/* Prototype : bool rmdir(string dirname[, resource context]) 13 * Description: Remove a directory 14 * Source code: ext/standard/file.c 15 * Alias to functions: 16 */ 17 18echo "*** Testing rmdir() : variation ***\n"; 19 20$workDir = "rmdirVar3.tmp"; 21$subDir = "aSubDir"; 22mkdir($workDir); 23$cwd = getcwd(); 24 25$unixifiedDir = '/'.substr(str_replace('\\','/',$cwd).'/'.$workDir.'/'.$subDir, 3); 26 27$dirs = array( 28 // relative 29 $workDir.'\\'.$subDir, 30 '.\\'.$workDir.'\\'.$subDir, 31 $workDir.'\\..\\'.$workDir.'\\'.$subDir, 32 33 // relative bad path 34 $workDir.'\\..\\BADDIR\\'.$subDir, 35 'BADDIR\\'.$subDir, 36 37 //absolute 38 $cwd.'\\'.$workDir.'\\'.$subDir, 39 $cwd.'\\.\\'.$workDir.'\\'.$subDir, 40 $cwd.'\\'.$workDir.'\\..\\'.$workDir.'\\'.$subDir, 41 42 //absolute bad path 43 $cwd.'\\BADDIR\\'.$subDir, 44 45 //trailing separators 46 $workDir.'\\'.$subDir.'\\', 47 $cwd.'\\'.$workDir.'\\'.$subDir.'\\', 48 49 // multiple separators 50 $workDir.'\\\\'.$subDir, 51 $cwd.'\\\\'.$workDir.'\\\\'.$subDir, 52 53 // Unixified Dir 54 $unixifiedDir, 55 56 ); 57 58 59foreach($dirs as $dir) { 60 mkdir($workDir.'/'.$subDir); 61 echo "-- removing $dir --\n"; 62 $res = rmdir($dir); 63 if ($res === true) { 64 echo "Directory removed\n"; 65 } 66 else { 67 rmdir($workDir.'/'.$subDir); 68 } 69} 70 71rmdir($workDir); 72 73?> 74===DONE=== 75--EXPECTF-- 76*** Testing rmdir() : variation *** 77-- removing rmdirVar3.tmp\aSubDir -- 78Directory removed 79-- removing .\rmdirVar3.tmp\aSubDir -- 80Directory removed 81-- removing rmdirVar3.tmp\..\rmdirVar3.tmp\aSubDir -- 82Directory removed 83-- removing rmdirVar3.tmp\..\BADDIR\aSubDir -- 84 85Warning: rmdir(rmdirVar3.tmp\..\BADDIR\aSubDir): No such file or directory in %s on line %d 86-- removing BADDIR\aSubDir -- 87 88Warning: rmdir(BADDIR\aSubDir): No such file or directory in %s on line %d 89-- removing %s\rmdirVar3.tmp\aSubDir -- 90Directory removed 91-- removing %s\.\rmdirVar3.tmp\aSubDir -- 92Directory removed 93-- removing %s\rmdirVar3.tmp\..\rmdirVar3.tmp\aSubDir -- 94Directory removed 95-- removing %s\BADDIR\aSubDir -- 96 97Warning: rmdir(%s\BADDIR\aSubDir): No such file or directory in %s on line %d 98-- removing rmdirVar3.tmp\aSubDir\ -- 99Directory removed 100-- removing %s\rmdirVar3.tmp\aSubDir\ -- 101Directory removed 102-- removing rmdirVar3.tmp\\aSubDir -- 103Directory removed 104-- removing %s\\rmdirVar3.tmp\\aSubDir -- 105Directory removed 106-- removing /%s/rmdirVar3.tmp/aSubDir -- 107Directory removed 108===DONE===