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