1--TEST-- 2Test fileinode() function: Variations 3--SKIPIF-- 4<?php 5if (substr(PHP_OS, 0, 3) == 'WIN') { 6 die('skip no link()/symlink() on Windows'); 7} 8?> 9--FILE-- 10<?php 11/* 12Prototype: int fileinode ( string $filename ); 13Description: Returns the inode number of the file, or FALSE in case of an error. 14*/ 15 16echo "*** Testing fileinode() with files, links and directories ***\n"; 17$file_path = dirname(__FILE__); 18$file1 = $file_path."/fileinode1_variation.tmp"; 19$file2 = $file_path."/fileinode2_variation.tmp"; 20$link1 = $file_path."/fileinode1_variation_link.tmp"; 21$link2 = $file_path."/fileinode2_variation_link.tmp"; 22 23 24echo "-- Testing with files --\n"; 25//creating the files 26fclose( fopen( $file1, "w" ) ); 27fclose( fopen( $file2, "w" ) ); 28 29print( fileinode( $file1) )."\n"; 30print( fileinode( $file2) )."\n"; 31clearstatcache(); 32 33echo "-- Testing with links: hard link --\n"; 34link( $file1, $link1); // Creating an hard link 35print( fileinode( $file1) )."\n"; 36clearstatcache(); 37print( fileinode( $link1) )."\n"; 38clearstatcache(); 39 40echo "-- Testing with links: soft link --\n"; 41symlink( $file2, $link2); // Creating a soft link 42print( fileinode( $file2) )."\n"; 43clearstatcache(); 44print( fileinode( $link2) )."\n"; 45 46unlink( $link1 ); 47unlink( $link2 ); 48 49echo "-- Testing after copying a file --\n"; 50copy( $file1, $file_path."/fileinode1_variation_new.tmp"); 51print( fileinode( $file1) )."\n"; 52clearstatcache(); 53print( fileinode( $file_path."/fileinode1_variation_new.tmp") )."\n"; 54 55unlink( $file_path."/fileinode1_variation_new.tmp"); 56unlink( $file1); 57unlink( $file2); 58 59 60echo "-- Testing after renaming the file --\n"; 61fclose( fopen("$file_path/old.txt", "w") ); 62print( fileinode("$file_path/old.txt") )."\n"; 63clearstatcache(); 64 65rename("$file_path/old.txt", "$file_path/new.txt"); 66print( fileinode("$file_path/new.txt") )."\n"; 67 68unlink("$file_path/new.txt"); 69 70echo "-- Testing with directories --\n"; 71mkdir("$file_path/dir"); 72print( fileinode("$file_path/dir") )."\n"; 73clearstatcache(); 74 75mkdir("$file_path/dir/subdir"); 76print( fileinode("$file_path/dir/subdir") )."\n"; 77clearstatcache(); 78 79echo "-- Testing with binary input --\n"; 80print( fileinode(b"$file_path/dir") )."\n"; 81clearstatcache(); 82print( fileinode(b"$file_path/dir/subdir") ); 83 84rmdir("$file_path/dir/subdir"); 85rmdir("$file_path/dir"); 86 87echo "\n*** Done ***"; 88 89--EXPECTF-- 90*** Testing fileinode() with files, links and directories *** 91-- Testing with files -- 92%d 93%d 94-- Testing with links: hard link -- 95%d 96%d 97-- Testing with links: soft link -- 98%d 99%d 100-- Testing after copying a file -- 101%d 102%d 103-- Testing after renaming the file -- 104%d 105%d 106-- Testing with directories -- 107%d 108%d 109-- Testing with binary input -- 110%d 111%d 112*** Done *** 113