blob: ecbdeddf066fc307f16cc4a7a827464247ac4b59 (
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
|
--TEST--
Test ftruncate() function : error conditions
--FILE--
<?php
/*
Prototype: bool ftruncate ( resource $handle, int $size );
Description: truncates a file to a given length
*/
echo "*** Testing ftruncate() : error conditions ***\n";
$filename = dirname(__FILE__)."/ftruncate_error.tmp";
$file_handle = fopen($filename, "w" );
fwrite($file_handle, "Testing ftruncate error conditions \n");
fflush($file_handle);
echo "\n Initial file size = ".filesize($filename)."\n";
// ftruncate() on a file handle which is already closed/unset
echo "-- Testing ftruncate() with closed/unset file handle --\n";
// ftruncate on close file handle
fclose($file_handle);
var_dump( ftruncate($file_handle,10) );
// check the first size
var_dump( filesize($filename) );
echo "Done\n";
?>
--CLEAN--
<?php
$filename = dirname(__FILE__)."/ftruncate_error.tmp";
unlink( $filename );
?>
--EXPECTF--
*** Testing ftruncate() : error conditions ***
Initial file size = 36
-- Testing ftruncate() with closed/unset file handle --
Warning: ftruncate(): supplied resource is not a valid stream resource in %s on line %d
bool(false)
int(36)
Done
|