Bug #16211 Updated: ftruncate() won't truncate file

From: Date: Thu, 21 Mar 2002 22:05:51 +0000
Subject: Bug #16211 Updated: ftruncate() won't truncate file
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-3093@lists.php.net to get a copy of this message
ID: 16211 Updated by: mfischer@php.net Reported By: web-php-bugs@sklar.com -Status: Open +Status: Closed Bug Type: Filesystem function related Operating System: Red Hat Linux 7.1 / kernel 2.4.4 PHP Version: 4.0CVS-2002-03-21 New Comment: This bug has been fixed in CVS. Previous Comments: ------------------------------------------------------------------------ [2002-03-21 16:28:07] web-php-bugs@sklar.com Under the latest CVS, the following script fails (ftruncate() returns an error and doesn't truncate the file) but under PHP 4.1.2, it works fine: <?php if (! $fp = fopen('test','r+')) { die("Can't open test"); } if (! ftruncate($fp,0)) { die("Can't truncate"); } fclose($fp); ?> (The file "test" exists and has some text in it.) I get the same results whether the mode passed to fopen() is "r", "r+", "a", or "a+" (with "w" or "w+", the call to ftruncate() still fails, but the file is truncated due to the nature of the "w" fopen mode). ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=16211&edit=1

« previous php.bugs (#3093) next »