On the Arduino right now, there are many libraries to access different kinds of external or internal EEPROM or Flash memories but there's no single API to do that. It would be very nice to have a standard API with which to open, read and write to streams or files, similar to the fstream C++ library or the stdio (fopen, fprintf, etc).
The idea is to be able to use similar code wether you are writing to the uart, the EEPROM, a dataflash or an SD card.
Does such a library already exist? If not, I am ready to code one and I would like to use this post to discuss with the community about what is the best option.
I am considering two options.
1. Code a sub-class of Print.h that would implement additional functions for streams and files (such as open(), close(), rewind(), seek(), read(), etc.) -- which would permit, among other things, to use the
Streaming library for easiness.
Code example:
Dataflash f;
int x;
f.scanf("%d\n", &x);
f.rewind();
f.printf(f, "Hello word\n");
f.close();
2. Use the sdtio library (fopen, fprintf, etc.) The nice thing with this is that it's pretty standard for C users. It would be "the way to go" if Arduino had been designed for C users, but it's not -- and that's a good thing most of the time -- so it means that it's not very standard for Arduino users.
Code example (I don't even know if we can do that, I'm not super familiar with the stdio library):
FILE* f = open_dataflash();
int x;
fscanf(f, "%d\n", &x);
rewind(f);
fprintf(f, "Hello word\n");
fclose(f);
Any ideas, suggestions, questions?