xref: /PHP-7.2/ext/standard/tests/file/001-win32.phpt (revision f1d7e3ca)
1--TEST--
2File type functions
3--CREDITS--
4Dave Kelsey <d_kelsey@uk.ibm.com>
5--SKIPIF--
6<?php
7if (substr(PHP_OS, 0, 3) != 'WIN') {
8    die('skip only for Windows');
9}
10?>
11--FILE--
12<?php
13chdir(dirname(__FILE__));
14@unlink('test.file');
15if (file_exists('test.file')) {
16    echo "test.file exists\n";
17} else {
18    echo "test.file does not exist\n";
19}
20fclose (fopen('test.file', 'w'));
21chmod ('test.file', 0744);
22if (file_exists('test.file')) {
23    echo "test.file exists\n";
24} else {
25    echo "test.file does not exist\n";
26}
27if (is_link('test.file')) {
28    echo "test.file is a symlink\n";
29} else {
30    echo "test.file is not a symlink\n";
31}
32if (file_exists('test.file')) {
33    echo "test.file exists\n";
34} else {
35    echo "test.file does not exist\n";
36}
37$s = stat ('test.file');
38$ls = lstat ('test.file');
39for ($i = 0; $i <= 12; $i++) {
40    if ($ls[$i] != $s[$i]) {
41        echo "test.file lstat and stat differ at element $i\n";
42    }
43}
44echo "test.file is " . filetype('test.file') . "\n";
45printf ("test.file permissions are 0%o\n", 0777 & fileperms('test.file'));
46echo "test.file size is " . filesize('test.file') . "\n";
47if (is_writeable('test.file')) {
48    echo "test.file is writeable\n";
49} else {
50    echo "test.file is not writeable\n";
51}
52if (is_readable('test.file')) {
53    echo "test.file is readable\n";
54} else {
55    echo "test.file is not readable\n";
56}
57if (is_file('test.file')) {
58    echo "test.file is a regular file\n";
59} else {
60    echo "test.file is not a regular file\n";
61}
62if (is_dir('../file')) {
63    echo "../file is a directory\n";
64} else {
65    echo "../file is not a directory\n";
66}
67if (is_dir('test.file')) {
68    echo "test.file is a directory\n";
69} else {
70    echo "test.file is not a directory\n";
71}
72unlink('test.file');
73if (file_exists('test.file')) {
74    echo "test.file exists (cached)\n";
75} else {
76    echo "test.file does not exist\n";
77}
78clearstatcache();
79if (file_exists('test.file')) {
80    echo "test.file exists\n";
81} else {
82    echo "test.file does not exist\n";
83}
84?>
85--EXPECT--
86test.file does not exist
87test.file exists
88test.file is not a symlink
89test.file exists
90test.file is file
91test.file permissions are 0666
92test.file size is 0
93test.file is writeable
94test.file is readable
95test.file is a regular file
96../file is a directory
97test.file is not a directory
98test.file does not exist
99test.file does not exist
100