FatFS add dir checks
This commit is contained in:
5
ce/ce.c
5
ce/ce.c
@@ -431,10 +431,13 @@ static void ls (struct context* context, const char* path_string) {
|
||||
cprintf (context, "\n");
|
||||
|
||||
for (size_t entry_num = 0; entry_num < entries; entry_num++) {
|
||||
memset (&desc, 0, sizeof (desc));
|
||||
memset (&entry, 0, sizeof (entry));
|
||||
|
||||
read_dir_entry (path, &entry, entry_num);
|
||||
describe (entry.path, &desc);
|
||||
|
||||
cprintf (context, "%-40s%c %-40zu\n", entry.path, (desc.type == FS_DIR ? '*' : ' '), desc.size);
|
||||
cprintf (context, "%c%-40s %-40zu\n", (desc.type == FS_DIR ? '*' : ' '), entry.path, desc.size);
|
||||
}
|
||||
|
||||
volume_close ();
|
||||
|
||||
@@ -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