mirror of
https://github.com/lvgl/lvgl.git
synced 2026-05-27 03:25:28 +08:00
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:
@@ -105,15 +105,15 @@ static void * fs_open(lv_fs_drv_t * drv, const char * path, lv_fs_mode_t mode)
|
|||||||
LV_UNUSED(drv);
|
LV_UNUSED(drv);
|
||||||
|
|
||||||
uint32_t flags = 0;
|
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_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)*/
|
/*Make the path relative to the current directory (the projects root folder)*/
|
||||||
char buf[256];
|
char buf[256];
|
||||||
lv_snprintf(buf, sizeof(buf), LV_FS_POSIX_PATH "%s", path);
|
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;
|
if(f < 0) return NULL;
|
||||||
|
|
||||||
return (void *)(lv_uintptr_t)f;
|
return (void *)(lv_uintptr_t)f;
|
||||||
|
|||||||
Reference in New Issue
Block a user