Annotation of embedaddon/php/ext/standard/tests/file/ftruncate.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: ftruncate() tests
3: --FILE--
4: <?php
5:
6: $filename = dirname(__FILE__)."/ftruncate.dat";
7:
8: file_put_contents($filename, "some test data inside");
9:
10: $fp = fopen($filename, "r");
11: var_dump(ftruncate($fp, 10));
12: fclose($fp);
13: var_dump(file_get_contents($filename));
14:
15: $fp = fopen($filename, "w");
16: var_dump(ftruncate($fp, 10));
17: fclose($fp);
18: var_dump(file_get_contents($filename));
19:
20: file_put_contents($filename, "some test data inside");
21:
22: $fp = fopen($filename, "a");
23: var_dump(ftruncate($fp, 10));
24: fclose($fp);
25: var_dump(file_get_contents($filename));
26:
27: $fp = fopen($filename, "a");
28: var_dump(ftruncate($fp, 0));
29: fclose($fp);
30: var_dump(file_get_contents($filename));
31:
32: file_put_contents($filename, "some test data inside");
33:
34: $fp = fopen($filename, "a");
35: var_dump(ftruncate($fp, -1000000000));
36: fclose($fp);
37: var_dump(file_get_contents($filename));
38:
39: @unlink($filename);
40: echo "Done\n";
41: ?>
42: --EXPECTF--
43: bool(false)
44: string(21) "some test data inside"
45: bool(true)
46: string(10) "