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
12echo "*** Testing rmdir() : variation ***\n";
13
14$workDir = "rmdirVar3.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   mkdir($workDir.'/'.$subDir);
55   echo "-- removing $dir --\n";
56   $res = rmdir($dir);
57   if ($res === true) {
58      echo "Directory removed\n";
59   }
60   else {
61      rmdir($workDir.'/'.$subDir);
62   }
63}
64
65rmdir($workDir);
66
67?>
68--EXPECTF--
69*** Testing rmdir() : variation ***
70-- removing rmdirVar3.tmp\aSubDir --
71Directory removed
72-- removing .\rmdirVar3.tmp\aSubDir --
73Directory removed
74-- removing rmdirVar3.tmp\..\rmdirVar3.tmp\aSubDir --
75Directory removed
76-- removing rmdirVar3.tmp\..\BADDIR\aSubDir --
77
78Warning: rmdir(rmdirVar3.tmp\..\BADDIR\aSubDir): No such file or directory in %s on line %d
79-- removing BADDIR\aSubDir --
80
81Warning: rmdir(BADDIR\aSubDir): No such file or directory in %s on line %d
82-- removing %s\rmdirVar3.tmp\aSubDir --
83Directory removed
84-- removing %s\.\rmdirVar3.tmp\aSubDir --
85Directory removed
86-- removing %s\rmdirVar3.tmp\..\rmdirVar3.tmp\aSubDir --
87Directory removed
88-- removing %s\BADDIR\aSubDir --
89
90Warning: rmdir(%s\BADDIR\aSubDir): No such file or directory in %s on line %d
91-- removing rmdirVar3.tmp\aSubDir\ --
92Directory removed
93-- removing %s\rmdirVar3.tmp\aSubDir\ --
94Directory removed
95-- removing rmdirVar3.tmp\\aSubDir --
96Directory removed
97-- removing %s\\rmdirVar3.tmp\\aSubDir --
98Directory removed
99-- removing /%s/rmdirVar3.tmp/aSubDir --
100Directory removed
101