1--TEST--
2Test copy() function: usage variations - links
3--SKIPIF--
4<?php
5if(substr(PHP_OS, 0, 3) == "WIN")
6  die("skip Invalid for Windows");
7?>
8--FILE--
9<?php
10/* Test copy() function: Trying to create copy of links */
11
12$file_path = __DIR__;
13
14echo "*** Testing copy() with symlink and hardlink ***\n";
15$file = $file_path."/copy_variation7.tmp";
16$file_handle = fopen($file, "w");
17fwrite( $file_handle, str_repeat("Hello World, this is 2007 year ....\n", 100) );
18fclose($file_handle);
19
20$symlink = $file_path."/copy_variation7_symlink.tmp";
21$hardlink = $file_path."/copy_variation7_hardlink.tmp";
22
23symlink($file, $symlink);  //creating symlink
24link($file, $hardlink);  //creating hardlink
25
26echo "Size of source files => \n";
27var_dump( filesize($file_path."/copy_variation7_symlink.tmp") );  //size of the symlink itself
28clearstatcache();
29var_dump( filesize($file_path."/copy_variation7_hardlink.tmp") );  //size of the file
30clearstatcache();
31
32echo "-- Now applying copy() on source link to create copies --\n";
33echo "-- With symlink --\n";
34var_dump( copy($symlink, $file_path."/copy_copy_variation7_symlink.tmp") );
35var_dump( file_exists($file_path."/copy_copy_variation7_symlink.tmp") );
36var_dump( is_link($file_path."/copy_copy_variation7_symlink.tmp") );
37var_dump( is_file($file_path."/copy_copy_variation7_symlink.tmp") );
38var_dump( filesize($file_path."/copy_copy_variation7_symlink.tmp") );
39clearstatcache();
40
41echo "-- With hardlink --\n";
42var_dump( copy($hardlink, $file_path."/copy_copy_variation7_hardlink.tmp") );
43var_dump( file_exists($file_path."/copy_copy_variation7_hardlink.tmp") );
44var_dump( is_link($file_path."/copy_copy_variation7_hardlink.tmp") );
45var_dump( is_file($file_path."/copy_copy_variation7_hardlink.tmp") );
46var_dump( filesize($file_path."/copy_copy_variation7_hardlink.tmp") );
47clearstatcache();
48
49echo "*** Done ***\n";
50?>
51--CLEAN--
52<?php
53$file_path = __DIR__;
54unlink($file_path."/copy_copy_variation7_symlink.tmp");
55unlink($file_path."/copy_copy_variation7_hardlink.tmp");
56unlink($file_path."/copy_variation7_symlink.tmp");
57unlink($file_path."/copy_variation7_hardlink.tmp");
58unlink($file_path."/copy_variation7.tmp");
59?>
60--EXPECTF--
61*** Testing copy() with symlink and hardlink ***
62Size of source files =>
63int(%d)
64int(3600)
65-- Now applying copy() on source link to create copies --
66-- With symlink --
67bool(true)
68bool(true)
69bool(false)
70bool(true)
71int(3600)
72-- With hardlink --
73bool(true)
74bool(true)
75bool(false)
76bool(true)
77int(3600)
78*** Done ***
79