1--TEST--
2Test is_dir() function: usage variations - links
3--SKIPIF--
4<?php
5if (substr(PHP_OS, 0, 3) == 'WIN') {
6    die('skip Do not run on Windows');
7}
8--FILE--
9<?php
10/* Prototype: bool is_dir ( string $dirname );
11   Description: Tells whether the dirname is a directory
12     Returns TRUE if the dirname exists and is a directory, FALSE  otherwise.
13*/
14
15/* Testing is_dir() with dir, soft & hard link to dir,
16     and with file, soft & hard link to file */
17
18$file_path = dirname(__FILE__);
19
20echo "*** Testing is_dir() with dir and links to dir ***\n";
21echo "-- With dir --\n";
22$dirname = $file_path."/is_dir_variation2";
23mkdir($dirname);
24var_dump( is_dir($dirname) );
25clearstatcache();
26
27echo "-- With symlink --\n";
28symlink($file_path."/is_dir_variation2", $file_path."/is_dir_variation2_symlink");
29var_dump( is_dir($file_path."/is_dir_variation2_symlink") );  //is_dir() resolves symlinks
30clearstatcache();
31
32echo "-- With hardlink --";
33link($file_path."/is_dir_variation2", $file_path."/is_dir_variation2_link"); //Not permitted to create hard-link to a dir
34var_dump( is_dir($file_path."/is_dir_variation2_link") );
35clearstatcache();
36
37echo "\n*** Testing is_dir() with file and links to a file ***\n";
38echo "-- With file --\n";
39$filename = $file_path."/is_dir_variation2.tmp";
40fclose( fopen($filename, "w") );
41var_dump( is_dir($filename) );
42clearstatcache();
43
44echo "-- With symlink --\n";
45symlink($file_path."/is_dir_variation2.tmp", $file_path."/is_dir_variation2_symlink.tmp");
46var_dump( is_dir($file_path."/is_dir_variation2_symlink.tmp") );
47clearstatcache();
48
49echo "-- With hardlink --\n";
50link($file_path."/is_dir_variation2.tmp", $file_path."/is_dir_variation2_link.tmp");
51var_dump( is_dir($file_path."/is_dir_variation2_link.tmp") );
52clearstatcache();
53
54echo "\n*** Done ***";
55?>
56--CLEAN--
57<?php
58$file_path = dirname(__FILE__);
59if(file_exists($file_path."/is_dir_variation2_symlink")) {
60  unlink($file_path."/is_dir_variation2_symlink");
61}
62if(file_exists($file_path."/is_dir_variation2_symlink")) {
63  unlink($file_path."/is_dir_variation2_symlink");
64}
65if(file_exists($file_path."/is_dir_variation2_symlink.tmp")) {
66  unlink($file_path."/is_dir_variation2_symlink.tmp");
67}
68if(file_exists($file_path."/is_dir_variation2_link.tmp")) {
69  unlink($file_path."/is_dir_variation2_link.tmp");
70}
71if(file_exists($file_path."/is_dir_variation2.tmp")) {
72  unlink($file_path."/is_dir_variation2.tmp");
73}
74if(file_exists($file_path."/is_dir_variation2")) {
75  rmdir($file_path."/is_dir_variation2");
76}
77?>
78--EXPECTF--
79*** Testing is_dir() with dir and links to dir ***
80-- With dir --
81bool(true)
82-- With symlink --
83bool(true)
84-- With hardlink --
85Warning: link(): %s in %s on line %d
86bool(false)
87
88*** Testing is_dir() with file and links to a file ***
89-- With file --
90bool(false)
91-- With symlink --
92bool(false)
93-- With hardlink --
94bool(false)
95
96*** Done ***
97