Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

File base class #114

Open
PaulStoffregen opened this issue May 17, 2020 · 2 comments
Open

File base class #114

PaulStoffregen opened this issue May 17, 2020 · 2 comments

Comments

@PaulStoffregen
Copy link
Sponsor

Similar to Print, Stream, Client, Server... we probably need a File base class.

Currently File is defined in the SD library, and also in the Bridge library for Yun. Most programs in the Arduino ecosystem which use files are tied to the SD library. Because they include SD.h in their headers, the SD library is automatically brought into the project.

But the SD library isn't the only possible source for files. Flash chips, USB mass storage, network filesystems can also provide files. Without a base class, each library using files needs to be edited.

Use of alternate SD card libraries, like SdFat, is also very difficult without a base class because so many libraries which consume files are SD.h included by their code.

Hopefully the time has come to move File out of the SD library and into an abstract base class?

@PaulStoffregen
Copy link
Sponsor Author

PaulStoffregen commented Oct 31, 2020

I've recently been working on File base class for Teensy. Details here:

https://forum.pjrc.com/threads/64136-File-abstraction-and-SdFat-integration

Turns out the ESP8266 and ESP32 cores have implemented a File base class for quite some time. Looks like they ran into similar "C++ slicing" issues and solved them with a complicated set of classes which seem to build on top of a virtual filesystem layer inside their SDK. I'm trying to follow some of ESP32's conventions where there's nothing from Arduino...

I also looked the the Portenta core today. The Portenta_SDCARD library has a TestSDCARD example which looks pretty much nothing like Arduino's API. :(

@fabianoriccardi
Copy link

Any news on File and File System? Also referenced here #16
I have looked at esp8266 and esp32, they seem pretty clear and intuitive. In ESP8266 core, there is also the concept of directory (Dir class).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants