php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #16211 ftruncate() won't truncate file
Submitted: 2002-03-21 16:28 UTC Modified: 2002-03-21 17:05 UTC
From: web-php-bugs at sklar dot com Assigned:
Status: Closed Package: Filesystem function related
PHP Version: 4.0CVS-2002-03-21 OS: Red Hat Linux 7.1 / kernel 2.4.4
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: web-php-bugs at sklar dot com
New email:
PHP Version: OS:

 

 [2002-03-21 16:28 UTC] web-php-bugs at sklar dot 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).


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-03-21 17:05 UTC] mfischer@php.net
This bug has been fixed in CVS.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 26 00:01:30 2024 UTC