Berry allow import from file system

This commit is contained in:
Stephan Hadinger 2021-05-22 15:10:13 +02:00
parent cb50580e66
commit e2865e22d4
1 changed files with 8 additions and 1 deletions

View File

@ -95,8 +95,15 @@ BERRY_API char* be_readstring(char *buffer, size_t size)
void* be_fopen(const char *filename, const char *modes)
{
if (ufsp != nullptr && filename != nullptr && modes != nullptr) {
char fname2[strlen(filename) + 2];
if (filename[0] == '/') {
strcpy(fname2, filename); // copy unchanged
} else {
fname2[0] = '/';
strcpy(fname2 + 1, filename); // prepend with '/'
}
// Serial.printf("be_fopen filename=%s, modes=%s\n", filename, modes);
File f = ufsp->open(filename, modes); // returns an object, not a pointer
File f = ufsp->open(fname2, modes); // returns an object, not a pointer
if (f) {
File * f_ptr = new File(f); // copy to dynamic object
*f_ptr = f; // TODO is this necessary?