1--TEST-- 2Test mkdir() 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 mkdir(string pathname [, int mode [, bool recursive [, resource context]]]) 13 * Description: Create a directory 14 * Source code: ext/standard/file.c 15 * Alias to functions: 16 */ 17 18echo "*** Testing mkdir() : variation ***\n"; 19 20$workDir = "mkdirVar5.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 echo "-- creating $dir --\n"; 61 $res = mkdir($dir); 62 if ($res === true) { 63 echo "Directory created\n"; 64 rmdir($workDir.'\\'.$subDir); 65 } 66} 67 68rmdir($workDir); 69 70?> 71===DONE=== 72--EXPECTF-- 73*** Testing mkdir() : variation *** 74-- creating mkdirVar5.tmp\aSubDir -- 75Directory created 76-- creating .\mkdirVar5.tmp\aSubDir -- 77Directory created 78-- creating mkdirVar5.tmp\..\mkdirVar5.tmp\aSubDir -- 79Directory created 80-- creating mkdirVar5.tmp\..\BADDIR\aSubDir -- 81 82Warning: mkdir(): No such file or directory in %s on line %d 83-- creating BADDIR\aSubDir -- 84 85Warning: mkdir(): No such file or directory in %s on line %d 86-- creating %s\mkdirVar5.tmp\aSubDir -- 87Directory created 88-- creating %s\.\mkdirVar5.tmp\aSubDir -- 89Directory created 90-- creating %s\mkdirVar5.tmp\..\mkdirVar5.tmp\aSubDir -- 91Directory created 92-- creating %s\BADDIR\aSubDir -- 93 94Warning: mkdir(): No such file or directory in %s on line %d 95-- creating mkdirVar5.tmp\aSubDir\ -- 96Directory created 97-- creating %s\mkdirVar5.tmp\aSubDir\ -- 98Directory created 99-- creating mkdirVar5.tmp\\aSubDir -- 100Directory created 101-- creating %s\\mkdirVar5.tmp\\aSubDir -- 102Directory created 103-- creating /%s/mkdirVar5.tmp/aSubDir -- 104Directory created 105===DONE=== 106