Bug #16211: ftruncate() won't truncate file
| From: | web-php-bugs at sklar dot com | Date: | Thu, 21 Mar 2002 21:28:08 +0000 |
| Subject: | Bug #16211: ftruncate() won't truncate file | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-3086@lists.php.net to get a copy of this message | ||
From: web-php-bugs@sklar.com
Operating system: Red Hat Linux 7.1 / kernel 2.4.4
PHP version: 4.0CVS-2002-03-21
PHP Bug Type: Filesystem function related
Bug description: ftruncate() won't truncate file
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 bug report at http://bugs.php.net/?id=16211&edit=1
--
Fixed in CVS: http://bugs.php.net/fix.php?id=16211&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=16211&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=16211&r=needtrace
Try newer version: http://bugs.php.net/fix.php?id=16211&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=16211&r=support
Expected behavior: http://bugs.php.net/fix.php?id=16211&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=16211&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=16211&r=submittedtwice