Signed-off-by: kevin <kevin@lmve.net>

This commit is contained in:
2026-02-21 14:36:44 +08:00
parent a7dabdb925
commit da7ed99c15
2 changed files with 21 additions and 11 deletions
+20 -10
View File
@@ -157,7 +157,9 @@ static lv_fs_res_t fs_close(lv_fs_drv_t *drv, void *file_p)
lv_fs_res_t res = LV_FS_RES_NOT_IMP;
int r = fclose(file_p);
FILE *f = (FILE *)file_p;
int r = fclose(f);
if (r != 0)
{
@@ -192,20 +194,25 @@ static lv_fs_res_t fs_read(lv_fs_drv_t *drv, void *file_p, void *buf, uint32_t b
FILE *f = (FILE *)file_p;
size_t bytes_read = fread(buf, 1, btr, f);
*br = (uint32_t)bytes_read;
uint32_t bytes_read_int32 = (uint32_t)bytes_read;
if (*br == btr)
if (br != NULL) // 逆天 居然会传入NULL
{
*br = bytes_read_int32;
}
if (bytes_read_int32 == btr)
{
res = LV_FS_RES_OK;
}
else
{
ESP_LOGE(TAG, "文件读取字节数量错误需要读取%lu 已读取%lu", btr, *br);
ESP_LOGE(TAG, "文件读取字节数量错误需要读取%lu 已读取%lu", btr, bytes_read_int32);
res = LV_FS_RES_UNKNOWN;
}
ESP_LOGI(TAG, "文件读取字节数量:读取%lu 已读取%lu", btr, *br);
ESP_LOGI(TAG, "文件读取字节数量:读取%lu 已读取%lu", btr, bytes_read_int32);
return res;
}
@@ -228,16 +235,19 @@ static lv_fs_res_t fs_write(lv_fs_drv_t *drv, void *file_p, const void *buf, uin
FILE *f = (FILE *)file_p;
size_t bytes_written = fwrite(buf, 1, btw, f);
*bw = (uint32_t)bytes_written;
if (*bw == btw)
uint32_t bytes_written_int32 = (uint32_t)bytes_written;
if (bw != NULL)
{
*bw = bytes_written_int32;
}
if (bytes_written_int32 == btw)
{
res = LV_FS_RES_OK;
}
else
{
ESP_LOGE(TAG, "文件写入字节数量错误需要写入%lu 已写入%lu", btw, *bw);
ESP_LOGE(TAG, "文件写入字节数量错误需要写入%lu 已写入%lu", btw, bytes_written_int32);
res = LV_FS_RES_UNKNOWN;
}
@@ -257,7 +267,7 @@ static lv_fs_res_t fs_seek(lv_fs_drv_t *drv, void *file_p, uint32_t pos, lv_fs_w
lv_fs_res_t res = LV_FS_RES_NOT_IMP;
/*Add your code here*/
ESP_LOGI(TAG, "fs_seek:pop%lu whence%d",pos,whence);
ESP_LOGI(TAG, "fs_seek:pop%lu whence%d", pos, whence);
FILE *f = (FILE *)file_p;
int std_whence;