1--TEST--
2Test fileinode() function: usage variations - diff. path notations
3--CREDITS--
4Dave Kelsey <d_kelsey@uk.ibm.com>
5--FILE--
6<?php
7/* Passing file names with different notations, using slashes, wild-card chars */
8
9$file_path = __DIR__;
10
11echo "*** Testing fileinode() with different notations of file names ***\n";
12$dir_name = $file_path."/fileinode_variation3";
13mkdir($dir_name);
14$file_handle = fopen($dir_name."/fileinode_variation3.tmp", "w");
15fclose($file_handle);
16
17$files_arr = array(
18  "/fileinode_variation3/fileinode_variation3.tmp",
19
20  /* Testing a file trailing slash */
21  "/fileinode_variation3/fileinode_variation3.tmp/",
22
23  /* Testing file with double slashes */
24  "/fileinode_variation3//fileinode_variation3.tmp",
25  "//fileinode_variation3//fileinode_variation3.tmp",
26  "/fileinode_variation3/*.tmp",
27  "fileinode_variation3/fileinode*.tmp",
28
29  /* Testing Binary safe */
30  "/fileinode_variation3/fileinode_variation3.tmp".chr(0),
31  "/fileinode_variation3/fileinode_variation3.tmp\0"
32);
33
34$count = 1;
35/* loop through to test each element in the above array */
36foreach($files_arr as $file) {
37  echo "- Iteration $count -\n";
38  try {
39    var_dump( fileinode( $file_path."/".$file ) );
40  } catch (Error $e) {
41    echo $e->getMessage(), "\n";
42  }
43  clearstatcache();
44  $count++;
45}
46
47echo "\n*** Done ***";
48?>
49--CLEAN--
50<?php
51$file_path = __DIR__;
52$dir_name = $file_path."/fileinode_variation3";
53unlink($dir_name."/fileinode_variation3.tmp");
54rmdir($dir_name);
55?>
56--EXPECTF--
57*** Testing fileinode() with different notations of file names ***
58- Iteration 1 -
59int(%i)
60- Iteration 2 -
61
62Warning: fileinode(): stat failed for %s//fileinode_variation3/fileinode_variation3.tmp/ in %s on line %d
63bool(false)
64- Iteration 3 -
65int(%i)
66- Iteration 4 -
67int(%i)
68- Iteration 5 -
69
70Warning: fileinode(): stat failed for %s//fileinode_variation3/*.tmp in %s on line %d
71bool(false)
72- Iteration 6 -
73
74Warning: fileinode(): stat failed for %s/fileinode_variation3/fileinode*.tmp in %s on line %d
75bool(false)
76- Iteration 7 -
77
78Warning: fileinode(): Filename contains null byte in %s on line %d
79bool(false)
80- Iteration 8 -
81
82Warning: fileinode(): Filename contains null byte in %s on line %d
83bool(false)
84
85*** Done ***
86