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

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

many years FILE_WRITE define was without O_APPEND

Juraj:
SD/src/SD.h at 659ee9e3500c7742ceee7920646262cd32bf65e7 · arduino-libraries/SD · GitHub

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

I thought that was fixed a long time ago?

-jim lee