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