mirror of
https://github.com/nodemcu/nodemcu-firmware.git
synced 2025-02-06 21:18:25 +08:00
e49f2bb13f
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.
29 lines
649 B
C
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;
|
|
}
|
|
}
|