fix(fs_posix): allow creating new file and set permission. (#3976)

Signed-off-by: Neo Xu <neo.xu1990@gmail.com>
This commit is contained in:
Neo Xu
2023-02-08 17:01:02 +08:00
committed by GitHub
parent a12326ed2d
commit 3e2e867027
+3 -3
View File
@@ -105,15 +105,15 @@ static void * fs_open(lv_fs_drv_t * drv, const char * path, lv_fs_mode_t mode)
LV_UNUSED(drv);
uint32_t flags = 0;
if(mode == LV_FS_MODE_WR) flags = O_WRONLY;
if(mode == LV_FS_MODE_WR) flags = O_WRONLY | O_CREAT;
else if(mode == LV_FS_MODE_RD) flags = O_RDONLY;
else if(mode == (LV_FS_MODE_WR | LV_FS_MODE_RD)) flags = O_RDWR;
else if(mode == (LV_FS_MODE_WR | LV_FS_MODE_RD)) flags = O_RDWR | O_CREAT;
/*Make the path relative to the current directory (the projects root folder)*/
char buf[256];
lv_snprintf(buf, sizeof(buf), LV_FS_POSIX_PATH "%s", path);
int f = open(buf, flags);
int f = open(buf, flags, 0666);
if(f < 0) return NULL;
return (void *)(lv_uintptr_t)f;