12345678910111213141516171819202122232425262728 |
- #include "flash_fs.h"
- #include "c_string.h"
- #include "spiffs.h"
- int fs_mode2flag(const char *mode){
- if(c_strlen(mode)==1){
- if(c_strcmp(mode,"w")==0)
- return FS_WRONLY|FS_CREAT|FS_TRUNC;
- else if(c_strcmp(mode, "r")==0)
- return FS_RDONLY;
- else if(c_strcmp(mode, "a")==0)
- return FS_WRONLY|FS_CREAT|FS_APPEND;
- else
- return FS_RDONLY;
- } else if (c_strlen(mode)==2){
- if(c_strcmp(mode,"r+")==0)
- return FS_RDWR;
- else if(c_strcmp(mode, "w+")==0)
- return FS_RDWR|FS_CREAT|FS_TRUNC;
- else if(c_strcmp(mode, "a+")==0)
- return FS_RDWR|FS_CREAT|FS_APPEND;
- else
- return FS_RDONLY;
- } else {
- return FS_RDONLY;
- }
- }
|