#27575 [NEW]: ftell reports the size of appended bytes instead of the file pointer position

From: Date: Thu, 11 Mar 2004 19:33:11 +0000
Subject: #27575 [NEW]: ftell reports the size of appended bytes instead of the file pointer position
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-56339@lists.php.net to get a copy of this message
From: fbernardi at bbros dot it Operating system: Red Hat Linux PHP version: 4.3.4 PHP Bug Type: Filesystem function related Bug description: ftell reports the size of appended bytes instead of the file pointer position Description: ------------ ftell() reports the size of bytes added to a file instead of the position of the file pointer in the file. I guess this behavior is reproduceable only on appending data to a file, since on new files the file pointer position is at the same place of the number of bytes added. Reproduce code: --------------- <?php # Adding something to the test-file to see the behavior $fp = fopen("test", w); fwrite($fp, "Ciao"); fflush($fp); fclose($fp); # test-file saved and closed # Opening a file with non-zero size (just added some bytes) $fp = fopen("test", a); fwrite($fp, "Ciao"); fflush($fp); $s = filesize("test"); $t = ftell($fp); print("The pointer should be at the position $s, but ftell reports $t"); fclose($fp); ?> Expected result: ---------------- The pointer should be at the position 8, but ftell reports 8 Actual result: -------------- The pointer should be at the position 8, but ftell reports 4 -- Edit bug report at http://bugs.php.net/?id=27575&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=27575&r=trysnapshot4 Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=27575&r=trysnapshot5 Fixed in CVS: http://bugs.php.net/fix.php?id=27575&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=27575&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=27575&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=27575&r=needscript Try newer version: http://bugs.php.net/fix.php?id=27575&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=27575&r=support Expected behavior: http://bugs.php.net/fix.php?id=27575&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=27575&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=27575&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=27575&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=27575&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=27575&r=dst IIS Stability: http://bugs.php.net/fix.php?id=27575&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=27575&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=27575&r=float

« previous php.bugs (#56339) next »