2 <<__EntryPoint
>> function main(): void
{
3 $scratch = __SystemLib\
hphp_test_tmppath('file');
6 if (file_exists('test.file')) {
7 echo "test.file exists\n";
9 echo "test.file does not exist\n";
11 fclose (fopen('test.file', 'w'));
12 chmod ('test.file', 0744);
13 if (file_exists('test.file')) {
14 echo "test.file exists\n";
16 echo "test.file does not exist\n";
19 symlink('test.file','test.link');
20 if (file_exists('test.link')) {
21 echo "test.link exists\n";
23 echo "test.link does not exist\n";
25 if (is_link('test.file')) {
26 echo "test.file is a symlink\n";
28 echo "test.file is not a symlink\n";
30 if (is_link('test.link')) {
31 echo "test.link is a symlink\n";
33 echo "test.link is not a symlink\n";
35 if (file_exists('test.file')) {
36 echo "test.file exists\n";
38 echo "test.file does not exist\n";
40 $s = stat ('test.file');
41 $ls = lstat ('test.file');
42 for ($i = 0; $i <= 12; $i++
) {
43 if ($ls[$i] != $s[$i]) {
44 echo "test.file lstat and stat differ at element $i\n";
47 $s = stat ('test.link');
48 $ls = lstat ('test.link');
49 for ($i = 0; $i <= 11; $i++
) {
50 if ($ls[$i] != $s[$i]) {
51 if ($i != 6 && $i != 10 && $i != 11) echo "test.link lstat and stat differ at element $i\n";
54 echo "test.file is " . filetype('test.file') . "\n";
55 echo "test.link is " . filetype('test.link') . "\n";
56 printf ("test.file permissions are 0%o\n", 0777 & fileperms('test.file'));
57 echo "test.file size is " . filesize('test.file') . "\n";
58 if (is_writeable('test.file')) {
59 echo "test.file is writeable\n";
61 echo "test.file is not writeable\n";
63 if (is_readable('test.file')) {
64 echo "test.file is readable\n";
66 echo "test.file is not readable\n";
68 if (is_executable('test.file')) {
69 echo "test.file is executable\n";
71 echo "test.file is not executable\n";
73 if (is_file('test.file')) {
74 echo "test.file is a regular file\n";
76 echo "test.file is not a regular file\n";
78 if (is_file('test.link')) {
79 echo "test.link is a regular file\n";
81 echo "test.link is not a regular file\n";
83 if (is_dir('test.link')) {
84 echo "test.link is a directory\n";
86 echo "test.link is not a directory\n";
88 if (is_dir('../file')) {
89 echo "../file is a directory\n";
91 echo "../file is not a directory\n";
93 if (is_dir('test.file')) {
94 echo "test.file is a directory\n";
96 echo "test.file is not a directory\n";
100 if (file_exists('test.file')) {
101 echo "test.file exists (cached)\n";
103 echo "test.file does not exist\n";
106 if (file_exists('test.file')) {
107 echo "test.file exists\n";
109 echo "test.file does not exist\n";