summaryrefslogtreecommitdiff
path: root/ext/standard/tests/file/ftruncate_bug76422.phpt
blob: 4f434d324ab5548190cfa2987cb8399bb118a497 (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
--TEST--
Bug #76422 ftruncate fails on files > 2GB
--SKIPIF--
<?php
if (PHP_INT_SIZE < 8) {
    die('skip.. only valid for 64-bit');
}
?>
--FILE--
<?php

$fn = __DIR__ . DIRECTORY_SEPARATOR . "test76422";

$file_handle = fopen($fn,'cb');

if (false === $file_handle) {
    die('Cannot open test file :/');
}

$truncate_offset = 4 * 1024 * 1024 * 1024 + 1;
$ftruncate_result = ftruncate($file_handle, $truncate_offset);

if (false === $ftruncate_result) {
    die('Truncate has failed :/');
}

fclose($file_handle);
var_dump(filesize($fn) >= $truncate_offset);
?>
--CLEAN--
<?php
$fn = __DIR__ . "/test76422";
unlink($fn);
?>
--EXPECT--
bool(true)