2 /* Prototype : bool touch(string filename [, int time [, int atime]])
3 * Description: Set modification time of file
4 * Source code: ext/standard/filestat.c
8 $workDir = "touchVar5.tmp";
9 $subDirOrFile = "aSubDirOrFile";
15 $workDir.'/'.$subDirOrFile,
16 './'.$workDir.'/'.$subDirOrFile,
17 $workDir.'/../'.$workDir.'/'.$subDirOrFile,
20 $workDir.'/../BADDIR/'.$subDirOrFile,
21 'BADDIR/'.$subDirOrFile,
24 $cwd.'/'.$workDir.'/'.$subDirOrFile,
25 $cwd.'/./'.$workDir.'/'.$subDirOrFile,
26 $cwd.'/'.$workDir.'/../'.$workDir.'/'.$subDirOrFile,
29 $cwd.'/BADDIR/'.$subDirOrFile,
32 $workDir.'/'.$subDirOrFile.'/',
33 $cwd.'/'.$workDir.'/'.$subDirOrFile.'/',
35 // multiple separators
36 $workDir.'//'.$subDirOrFile,
37 $cwd.'//'.$workDir.'//'.$subDirOrFile,
41 echo "*** Testing touch() : variation ***\n";
43 echo "\n*** testing nonexisting paths ***\n";
44 test_nonexisting($paths);
46 echo "\n*** testing existing files ***\n";
47 test_existing($paths, false);
49 echo "\n*** testing existing directories ***\n";
50 test_existing($paths, true);
57 function test_nonexisting($paths) {
58 foreach($paths as $path) {
59 echo "--- testing $path ---\n";
61 if (is_dir($path) ||
is_file($path)) {
62 echo "FAILED: $path - exists\n";
67 // something was created
68 if (file_exists($path)) {
71 echo "FAILED: $path - unexpected directory\n";
74 echo "PASSED: $path - created\n";
80 echo "FAILED: $path - touch returned true, nothing there\n";
85 if (file_exists($path)) {
87 echo "FAILED: $path - touch returned false, something there\n";
100 function test_existing($paths, $are_dirs) {
101 foreach($paths as $path) {
103 $res = @mkdir
($path);
110 $h = @fopen
($path,"w");
121 function test_path($path) {
122 echo "--- testing $path ---\n";
123 $org_atime = get_atime($path);
125 $res = touch($path,0,0);
126 $next_atime = get_atime($path);
127 if ($next_atime == $org_atime) {
128 echo "FAILED: $path - access time not changed\n";
131 echo "PASSED: $path - touched\n";
135 function get_atime($path) {
137 return $temp['atime'];