FatFS add dir checks
This commit is contained in:
@@ -179,6 +179,9 @@ int fatfs_read_file (struct vfs_volume* volume, const char* path, uint8_t* buffe
|
||||
size_t size) {
|
||||
struct fatfs_ctx* fatfs_ctx = volume->udata;
|
||||
|
||||
if (fl_is_dir (fatfs_ctx, path))
|
||||
return -ST_NOT_FOUND;
|
||||
|
||||
FL_FILE* file = fl_fopen (fatfs_ctx, path, "wb+");
|
||||
|
||||
if (file == NULL)
|
||||
@@ -196,6 +199,9 @@ int fatfs_write_file (struct vfs_volume* volume, const char* path, uint8_t* buff
|
||||
size_t size) {
|
||||
struct fatfs_ctx* fatfs_ctx = volume->udata;
|
||||
|
||||
if (fl_is_dir (fatfs_ctx, path))
|
||||
return -ST_NOT_FOUND;
|
||||
|
||||
FL_FILE* file = fl_fopen (fatfs_ctx, path, "wb+");
|
||||
|
||||
if (file == NULL)
|
||||
@@ -214,6 +220,9 @@ int fatfs_read_dir_entry (struct vfs_volume* volume, const char* path, struct di
|
||||
struct fatfs_ctx* fatfs_ctx = volume->udata;
|
||||
FL_DIR dir;
|
||||
|
||||
if (!fl_is_dir (fatfs_ctx, path))
|
||||
return -ST_NOT_FOUND;
|
||||
|
||||
if (fl_opendir (fatfs_ctx, path, &dir) == NULL)
|
||||
return -ST_NOT_FOUND;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user