Johny Mattsson e49f2bb13f Remove conflicting libc, rename c_xx and os_xx to xx.
c_strtod and c_getenv are kept since strtod doesn't appear in the SDK's libc,
and we want our own c_getenv to initialize the Lua main anyway.
2016-05-26 18:50:20 +10:00

29 lines
649 B
C

#include "flash_fs.h"
#include <string.h>
#include "spiffs.h"
int fs_mode2flag(const char *mode){
if(strlen(mode)==1){
if(strcmp(mode,"w")==0)
return FS_WRONLY|FS_CREAT|FS_TRUNC;
else if(strcmp(mode, "r")==0)
return FS_RDONLY;
else if(strcmp(mode, "a")==0)
return FS_WRONLY|FS_CREAT|FS_APPEND;
else
return FS_RDONLY;
} else if (strlen(mode)==2){
if(strcmp(mode,"r+")==0)
return FS_RDWR;
else if(strcmp(mode, "w+")==0)
return FS_RDWR|FS_CREAT|FS_TRUNC;
else if(strcmp(mode, "a+")==0)
return FS_RDWR|FS_CREAT|FS_APPEND;
else
return FS_RDONLY;
} else {
return FS_RDONLY;
}
}