diff --git a/extmod/vfs_fat_misc.c b/extmod/vfs_fat_misc.c index f9f49b0d3b..bf9ce05cd1 100644 --- a/extmod/vfs_fat_misc.c +++ b/extmod/vfs_fat_misc.c @@ -34,6 +34,7 @@ #include "lib/fatfs/diskio.h" #include "extmod/vfs_fat_file.h" #include "fsusermount.h" +#include "py/lexer.h" #if _USE_LFN STATIC char lfn[_MAX_LFN + 1]; /* Buffer to store the LFN */ @@ -94,4 +95,21 @@ mp_obj_t fat_vfs_listdir(const char *path, bool is_str_type) { return dir_list; } +mp_import_stat_t fat_vfs_import_stat(const char *path) { + FILINFO fno; +#if _USE_LFN + fno.lfname = NULL; + fno.lfsize = 0; +#endif + FRESULT res = f_stat(path, &fno); + if (res == FR_OK) { + if ((fno.fattrib & AM_DIR) != 0) { + return MP_IMPORT_STAT_DIR; + } else { + return MP_IMPORT_STAT_FILE; + } + } + return MP_IMPORT_STAT_NO_EXIST; +} + #endif // MICROPY_VFS_FAT diff --git a/stmhal/import.c b/stmhal/import.c index c28fe87628..1edbe2caa1 100644 --- a/stmhal/import.c +++ b/stmhal/import.c @@ -29,19 +29,8 @@ #include "py/lexer.h" #include "lib/fatfs/ff.h" +mp_import_stat_t fat_vfs_import_stat(const char *path); + mp_import_stat_t mp_import_stat(const char *path) { - FILINFO fno; -#if _USE_LFN - fno.lfname = NULL; - fno.lfsize = 0; -#endif - FRESULT res = f_stat(path, &fno); - if (res == FR_OK) { - if ((fno.fattrib & AM_DIR) != 0) { - return MP_IMPORT_STAT_DIR; - } else { - return MP_IMPORT_STAT_FILE; - } - } - return MP_IMPORT_STAT_NO_EXIST; + return fat_vfs_import_stat(path); }