2014-12-22 12:35:05 +01:00
|
|
|
#include "flash_fs.h"
|
|
|
|
#include "c_string.h"
|
|
|
|
|
|
|
|
#if defined( BUILD_WOFS )
|
|
|
|
#include "romfs.h"
|
|
|
|
#elif defined( BUILD_SPIFFS )
|
|
|
|
#include "spiffs.h"
|
|
|
|
#endif
|
|
|
|
|
2015-01-05 03:09:51 +01:00
|
|
|
int fs_mode2flag(const char *mode){
|
2014-12-22 12:35:05 +01:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|