#32889 [Opn]: ftruncate doesn't move the file pointer
| From: | techtonik@php.net | Date: | Fri, 29 Apr 2005 10:12:58 +0000 |
| Subject: | #32889 [Opn]: ftruncate doesn't move the file pointer | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-78437@lists.php.net to get a copy of this message | ||
ID: 32889
User updated by: techtonik@php.net
Reported By: techtonik@php.net
Status: Open
-Bug Type: Documentation problem
+Bug Type: Filesystem function related
PHP Version: Irrelevant
New Comment:
On the second thought it doesn't seem like a feature.
Previous Comments:
------------------------------------------------------------------------
[2005-04-29 11:36:13] techtonik@php.net
Description:
------------
Note or warning here?
http://www.php.net/manual/en/function.ftruncate.php
Reproduce code:
---------------
<?php
// truncate doesn't move the file pointer to the end of the file
$flog = fopen("text.txt", "w+");
fwrite($flog, "veeery veeery long string");
fseek($flog, -2, SEEK_END);
ftruncate($flog, 6);
fwrite($flog, "shortstr");
fclose($flog);
?>
Expected result:
----------------
0000000000: 76 65 65 65 72 79 20 73 │ 68 6F 72 74 73 74 72
veeery shortstr
Actual result:
--------------
0000000000: 76 65 65 65 72 79 20 00 │ 00 00 00 00 00 00 00 00
veeery
0000000010: 00 00 00 00 00 00 00 73 │ 68 6F 72 74 73 74 72
shortstr
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=32889&edit=1