[En-Nut-Discussion] Strange behavior with files using file attributes '+' or 'a'

Andreas Helmcke ahnews01 at ela-soft.com
Tue Feb 26 23:08:03 CET 2008


Hi,

Michael Bieri wrote:
> I use an SD Card and PHAT filesystem for some (binary) files. It's no 
> problem to read or write files, but as soon as I use the file attributes 
> '+' or 'a' (so, if I try to modify an existing file), I get a very 
> strange behavior:
> 
> - Sometimes, the 'a' attribute doesn't append my data, it only appends 
> some trash with the same length at the end.
> - Sometimes, the 'a' attribute doesn't start "inserting"/appending data 
> at the end of my file, but inserts it at the beginning. fseek(..., 
> SEEK_END) does fix this problem.
> - If I try to insert some data with 'rb+', it behaves like an ordinary 
> 'w' (existing data is lost, but new data is there).
> 

I had similar problems when trying to append to an already existing file but 
didn't find by now the time to file a bug.
For me it works properly when opening the file with the correct attributes and 
doing fseek(...,0,SEEK_END) immediately afterwards.

Greetings
	Andreas







More information about the En-Nut-Discussion mailing list