FS#10587 - Lua plugin: bad behaviour for, 'w')

Attached to Project: Rockbox
Opened by Christophe Gragnic (Grahack) - Saturday, 05 September 2009, 07:21 GMT
Last edited by Maurus Cuelenaere (mcuelenaere) - Sunday, 06 September 2009, 21:42 GMT
Task Type Bugs
Category Plugins
Status Closed
Assigned To No-one
Operating System All players
Severity Low
Priority Normal
Reported Version Daily build (which?)
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No


If you write "some text" in a file with the 'w' flag, then write again "shorter" in the same file, the file will contain "shorterxt" (but should contain "shorter"). The length of the file didn't change.

You can try this with the little script I attached.
Everything is fine with the 'w+' flag though.

This occurs in r22628 and all previous versions.

The culprit should be around those lines:
This task depends upon

Closed by  Maurus Cuelenaere (mcuelenaere)
Sunday, 06 September 2009, 21:42 GMT
Reason for closing:  Fixed
Additional comments about closing:  In r22645.
Comment by Christophe Gragnic (Grahack) - Sunday, 06 September 2009, 20:54 GMT
I found a fix. The O_TRUNC flag was needed.
I filed a patch here: