#37505 [Opn->Csd]: touch() truncates large files
ID: 37505
Updated by: iliaa@php.net
Reported By: radu dot rendec at ines dot ro
-Status: Open
+Status: Closed
Bug Type: Streams related
Operating System: GNU/Linux i386
PHP Version: 5.1.5CVS
New Comment:
This bug has been fixed in CVS.
Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
Thank you for the report, and for helping us make PHP better.
Previous Comments:
------------------------------------------------------------------------
[2006-05-18 16:11:02] radu dot rendec at ines dot ro
Description:
------------
The touch() function truncates the file if it is a "large file" (i.e.
larger than 2GB).
Current PHP touch() implementation uses stat() to test if the file
already exists and only checks the return value, assuming that -1 means
the file does not exist. However, with large files, stat() fails with
"Value too large for defined data type".
Reproduce code:
---------------
<?php
touch("test");
?>
Expected result:
----------------
File "test" remains intact, only file times change.
Actual result:
--------------
File "test" is truncated to 0 (all contents is lost). This only happens
when "test" was larger than 2GB.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=37505&edit=1
Thread (2 messages)