1--TEST-- 2Bug #76422 ftruncate fails on files > 2GB 3--SKIPIF-- 4<?php 5if (PHP_INT_SIZE < 8) { 6 die('skip.. only valid for 64-bit'); 7} 8?> 9--FILE-- 10<?php 11 12$fn = __DIR__ . DIRECTORY_SEPARATOR . "test76422"; 13 14$file_handle = fopen($fn,'cb'); 15 16if (false === $file_handle) { 17 die('Cannot open test file :/'); 18} 19 20/* Check if ftruncate() with 2GB works. If it doesn't, it's likely that large files are 21 * generally not supported (EFBIG). */ 22$truncate_offset = 2 * 1024 * 1024 * 1024; 23$ftruncate_result = ftruncate($file_handle, $truncate_offset); 24if (false === $ftruncate_result) { 25 var_dump(true); 26 return; 27} 28 29$truncate_offset = 4 * 1024 * 1024 * 1024 + 1; 30$ftruncate_result = ftruncate($file_handle, $truncate_offset); 31 32if (false === $ftruncate_result) { 33 die('Truncate has failed :/'); 34} 35 36fclose($file_handle); 37var_dump(filesize($fn) >= $truncate_offset); 38?> 39--CLEAN-- 40<?php 41$fn = __DIR__ . "/test76422"; 42unlink($fn); 43?> 44--EXPECT-- 45bool(true) 46