What's the deal with FILE_READ and FILE_WRITE?

I have a library that does all sorts of things and it only uses FILE_WRITE. Seems to be able to read and write no problem.

I'm working on this new piece of code and if I open with FILE_WRITE.. It only lets me write. If I try reading I get 0 bytes bytes read. If I open it with FILE_READ then it works. It also works if I just omit the READ WRITE thing all together.

What's the rules here? The reference documentation seems a little spotty for this stuff.

Thanks!

-jim lee

https://github.com/arduino-libraries/SD/blob/659ee9e3500c7742ceee7920646262cd32bf65e7/src/SD.h#L23

If you open a file for write, it's going to append data to the file, so the current position in the file is the end. If you try to read from the file at that point, there's nothing more to read, as you observe.

wildbill: If you open a file for write, it's going to append data to the file, so the current position in the file is the end. If you try to read from the file at that point, there's nothing more to read, as you observe.

then this explains some things https://github.com/arduino-libraries/SD/commit/38cd35bb3ef6d31afbfbdafde372b0ffdf03849c#diff-a9c18581d236ab799038a90026216672

many years FILE_WRITE define was without O_APPEND

Juraj: https://github.com/arduino-libraries/SD/blob/659ee9e3500c7742ceee7920646262cd32bf65e7/src/SD.h#L23

// Note that currently only one file can be open at a time.

I thought that was fixed a long time ago?

-jim lee