3 * Prototype: int fileinode ( string $filename );
4 * Description: Returns the inode number of the file, or FALSE in case of an error.
6 <<__EntryPoint
>> function main(): void
{
7 echo "*** Testing fileinode() with files, links and directories ***\n";
8 $file1 = __SystemLib\
hphp_test_tmppath('fileinode1_variation.tmp');
9 $file2 = __SystemLib\
hphp_test_tmppath('fileinode2_variation.tmp');
10 $link1 = __SystemLib\
hphp_test_tmppath('fileinode1_variation_link.tmp');
11 $link2 = __SystemLib\
hphp_test_tmppath('fileinode2_variation_link.tmp');
14 echo "-- Testing with files --\n";
16 fclose( fopen( $file1, "w" ) );
17 fclose( fopen( $file2, "w" ) );
19 print( fileinode( $file1) )."\n";
20 print( fileinode( $file2) )."\n";
23 echo "-- Testing with links: hard link --\n";
24 link( $file1, $link1); // Creating an hard link
25 print( fileinode( $file1) )."\n";
27 print( fileinode( $link1) )."\n";
30 echo "-- Testing with links: soft link --\n";
31 symlink( $file2, $link2); // Creating a soft link
32 print( fileinode( $file2) )."\n";
34 print( fileinode( $link2) )."\n";
39 echo "-- Testing after copying a file --\n";
40 copy( $file1, __SystemLib\
hphp_test_tmppath('fileinode1_variation_new.tmp'));
41 print( fileinode( $file1) )."\n";
43 print( fileinode( __SystemLib\
hphp_test_tmppath('fileinode1_variation_new.tmp')) )."\n";
45 unlink( __SystemLib\
hphp_test_tmppath('fileinode1_variation_new.tmp'));
50 echo "-- Testing after renaming the file --\n";
51 fclose( fopen(__SystemLib\
hphp_test_tmppath('old.txt'), "w") );
52 print( fileinode(__SystemLib\
hphp_test_tmppath('old.txt')) )."\n";
56 __SystemLib\
hphp_test_tmppath('old.txt'),
57 __SystemLib\
hphp_test_tmppath('new.txt')
59 print( fileinode(__SystemLib\
hphp_test_tmppath('new.txt')) )."\n";
61 unlink(__SystemLib\
hphp_test_tmppath('new.txt'));
63 echo "-- Testing with directories --\n";
64 mkdir(__SystemLib\
hphp_test_tmppath('dir'));
65 print( fileinode(__SystemLib\
hphp_test_tmppath('dir')) )."\n";
68 mkdir(__SystemLib\
hphp_test_tmppath('dir/subdir'));
69 print( fileinode(__SystemLib\
hphp_test_tmppath('dir/subdir')) )."\n";
72 echo "-- Testing with binary input --\n";
73 print( fileinode(__SystemLib\
hphp_test_tmppath('dir')) )."\n";
75 print( fileinode(__SystemLib\
hphp_test_tmppath('dir/subdir')) );
77 rmdir(__SystemLib\
hphp_test_tmppath('dir/subdir'));
78 rmdir(__SystemLib\
hphp_test_tmppath('dir'));
80 echo "\n*** Done ***";