note 125539 added to function.ftruncate

From: Date: Tue, 24 Nov 2020 23:55:08 +0000
Subject: note 125539 added to function.ftruncate
Groups: php.notes 
Request: Send a blank email to php-notes+get-215894@lists.php.net to get a copy of this message
The problem that rc at opelgt dot org mentioned seems completely logical. When pointer is at offset 4 and you truncate file, the pointer is still at offset 4. So when you write(), the first 4 bytes are filled with null byte by Operating System - There is nothing wrong by PHP. And it's filled with null byte, because there is data on disk and that needs to be cleared with zero bits. Even though this is a Operating System's gotcha, to avoid data corruption, PHP Docs should mention it clearly. Also it would be nice if PHP automatically sets the pointer's offset to SEEK_END after truncating to an smaller size to fool-proof it. ---- Server IP: 45.112.84.4 Probable Submitter: 185.85.3.174 (proxied: 91.98.190.37) ---- Manual Page -- http://php.net/manual/en/function.ftruncate.php Edit -- https://master.php.net/note/edit/125539 Del: integrated -- https://master.php.net/note/delete/125539/integrated Del: useless -- https://master.php.net/note/delete/125539/useless Del: bad code -- https://master.php.net/note/delete/125539/bad+code Del: spam -- https://master.php.net/note/delete/125539/spam Del: non-english -- https://master.php.net/note/delete/125539/non-english Del: in docs -- https://master.php.net/note/delete/125539/in+docs Del: other reasons-- https://master.php.net/note/delete/125539 Reject -- https://master.php.net/note/reject/125539 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#215894) next »