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
12echo "*** Testing mkdir() : variation ***\n";
13
14$workDir = "mkdirVar5.tmp";
15$subDir = "aSubDir";
16mkdir($workDir);
17$cwd = getcwd();
18
19$unixifiedDir = '/'.substr(str_replace('\\','/',$cwd).'/'.$workDir.'/'.$subDir, 3);
20
21$dirs = array(
22             // relative
23             $workDir.'\\'.$subDir,
24             '.\\'.$workDir.'\\'.$subDir,
25             $workDir.'\\..\\'.$workDir.'\\'.$subDir,
26
27             // relative bad path
28             $workDir.'\\..\\BADDIR\\'.$subDir,
29             'BADDIR\\'.$subDir,
30
31             //absolute
32             $cwd.'\\'.$workDir.'\\'.$subDir,
33             $cwd.'\\.\\'.$workDir.'\\'.$subDir,
34             $cwd.'\\'.$workDir.'\\..\\'.$workDir.'\\'.$subDir,
35
36             //absolute bad path
37             $cwd.'\\BADDIR\\'.$subDir,
38
39             //trailing separators
40             $workDir.'\\'.$subDir.'\\',
41             $cwd.'\\'.$workDir.'\\'.$subDir.'\\',
42
43             // multiple separators
44             $workDir.'\\\\'.$subDir,
45             $cwd.'\\\\'.$workDir.'\\\\'.$subDir,
46
47             // Unixified Dir
48             $unixifiedDir,
49
50             );
51
52
53foreach($dirs as $dir) {
54   echo "-- creating $dir --\n";
55   $res = mkdir($dir);
56   if ($res === true) {
57      echo "Directory created\n";
58      rmdir($workDir.'\\'.$subDir);
59   }
60}
61
62rmdir($workDir);
63
64?>
65--EXPECTF--
66*** Testing mkdir() : variation ***
67-- creating mkdirVar5.tmp\aSubDir --
68Directory created
69-- creating .\mkdirVar5.tmp\aSubDir --
70Directory created
71-- creating mkdirVar5.tmp\..\mkdirVar5.tmp\aSubDir --
72Directory created
73-- creating mkdirVar5.tmp\..\BADDIR\aSubDir --
74
75Warning: mkdir(): No such file or directory in %s on line %d
76-- creating BADDIR\aSubDir --
77
78Warning: mkdir(): No such file or directory in %s on line %d
79-- creating %s\mkdirVar5.tmp\aSubDir --
80Directory created
81-- creating %s\.\mkdirVar5.tmp\aSubDir --
82Directory created
83-- creating %s\mkdirVar5.tmp\..\mkdirVar5.tmp\aSubDir --
84Directory created
85-- creating %s\BADDIR\aSubDir --
86
87Warning: mkdir(): No such file or directory in %s on line %d
88-- creating mkdirVar5.tmp\aSubDir\ --
89Directory created
90-- creating %s\mkdirVar5.tmp\aSubDir\ --
91Directory created
92-- creating mkdirVar5.tmp\\aSubDir --
93Directory created
94-- creating %s\\mkdirVar5.tmp\\aSubDir --
95Directory created
96-- creating /%s/mkdirVar5.tmp/aSubDir --
97Directory created
98