Annotation of embedaddon/php/ext/standard/tests/file/readfile_variation2.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test readfile() function: usage variations - links
3: --SKIPIF--
4: <?php
5: if (substr(PHP_OS, 0, 3) == 'WIN') {
6: die('skip.. only on Linux');
7: }
8: ?>
9: --FILE--
10: <?php
11: /* Prototype: int readfile ( string $filename [, bool $use_include_path [, resource $context]] );
12: Description: Outputs a file
13: */
14:
15: /* Variation 2 : Create file
16: Create soft/hard link to it
17: Read link using readfile()
18: Delete file and its link
19: */
20:
21: // include file.inc
22: require("file.inc");
23:
24: $file_path = dirname(__FILE__);
25:
26: // temp file used here
27: $filename = "$file_path/readfile_variation2.tmp";
28:
29: // create temp file and insert data into it
30: $fp = fopen($filename, "w");
31: fill_file($fp, "text_with_new_line", 50);
32: fclose($fp);
33:
34: // temp link name used
35: $linkname = "$file_path/readfile_variation2_link.tmp";
36:
37: /* Checking readfile() operation on soft link */
38: echo "*** Testing readfile() on soft link ***\n";
39:
40: // create soft link to $filename
41: var_dump( symlink($filename, $linkname) );
42: // readfile() on soft link
43: $count = readfile($linkname); // with default args
44: echo "\n";
45: var_dump($count);
46: // delete link
47: unlink($linkname);
48:
49: /* Checking readfile() operation on hard link */
50: echo "\n*** Testing readfile() on hard link ***\n";
51: // create hard link to $filename
52: var_dump( link($filename, $linkname) );
53: // readfile() on hard link
54: $count = readfile($linkname); // default args
55: echo "\n";
56: var_dump($count);
57: // delete link
58: unlink($linkname);
59:
60: echo "Done\n";
61: ?>
62: --CLEAN--
63: <?php
64: $file_path = dirname(__FILE__);
65: unlink("$file_path/readfile_variation2.tmp");
66: ?>
67: --EXPECTF--
68: *** Testing readfile() on soft link ***
69: bool(true)
70: line
71: line of text
72: line
73: line of text
74: line
75: line of t
76: int(50)
77:
78: *** Testing readfile() on hard link ***
79: bool(true)
80: line
81: line of text
82: line
83: line of text
84: line
85: line of t
86: int(50)
87: Done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>