diff --git a/extmod/vfs_fat.h b/extmod/vfs_fat.h index da56a90770..e0836a555b 100644 --- a/extmod/vfs_fat.h +++ b/extmod/vfs_fat.h @@ -55,6 +55,8 @@ typedef struct _fs_user_mount_t { extern const byte fresult_to_errno_table[20]; extern const mp_obj_type_t mp_fat_vfs_type; +extern const mp_obj_type_t mp_type_vfs_fat_fileio; +extern const mp_obj_type_t mp_type_vfs_fat_textio; mp_import_stat_t fat_vfs_import_stat(struct _fs_user_mount_t *vfs, const char *path); MP_DECLARE_CONST_FUN_OBJ_3(fat_vfs_open_obj); diff --git a/extmod/vfs_fat_file.c b/extmod/vfs_fat_file.c index cbd013f160..f7b9331b82 100644 --- a/extmod/vfs_fat_file.c +++ b/extmod/vfs_fat_file.c @@ -35,12 +35,6 @@ #include "lib/oofatfs/ff.h" #include "extmod/vfs_fat.h" -#define mp_type_fileio fatfs_type_fileio -#define mp_type_textio fatfs_type_textio - -extern const mp_obj_type_t mp_type_fileio; -extern const mp_obj_type_t mp_type_textio; - // this table converts from FRESULT to POSIX errno const byte fresult_to_errno_table[20] = { [FR_OK] = 0, @@ -189,11 +183,11 @@ STATIC mp_obj_t file_open(fs_user_mount_t *vfs, const mp_obj_type_t *type, mp_ar break; #if MICROPY_PY_IO_FILEIO case 'b': - type = &mp_type_fileio; + type = &mp_type_vfs_fat_fileio; break; #endif case 't': - type = &mp_type_textio; + type = &mp_type_vfs_fat_textio; break; } } @@ -249,7 +243,7 @@ STATIC const mp_stream_p_t fileio_stream_p = { .ioctl = file_obj_ioctl, }; -const mp_obj_type_t mp_type_fileio = { +const mp_obj_type_t mp_type_vfs_fat_fileio = { { &mp_type_type }, .name = MP_QSTR_FileIO, .print = file_obj_print, @@ -268,7 +262,7 @@ STATIC const mp_stream_p_t textio_stream_p = { .is_text = true, }; -const mp_obj_type_t mp_type_textio = { +const mp_obj_type_t mp_type_vfs_fat_textio = { { &mp_type_type }, .name = MP_QSTR_TextIOWrapper, .print = file_obj_print, @@ -287,7 +281,7 @@ STATIC mp_obj_t fatfs_builtin_open_self(mp_obj_t self_in, mp_obj_t path, mp_obj_ arg_vals[0].u_obj = path; arg_vals[1].u_obj = mode; arg_vals[2].u_obj = mp_const_none; - return file_open(self, &mp_type_textio, arg_vals); + return file_open(self, &mp_type_vfs_fat_textio, arg_vals); } MP_DEFINE_CONST_FUN_OBJ_3(fat_vfs_open_obj, fatfs_builtin_open_self); diff --git a/ports/cc3200/mpconfigport.h b/ports/cc3200/mpconfigport.h index 29ae9092b1..ee9a226e5c 100644 --- a/ports/cc3200/mpconfigport.h +++ b/ports/cc3200/mpconfigport.h @@ -131,8 +131,8 @@ X(ETIMEDOUT) \ // TODO these should be generic, not bound to fatfs -#define mp_type_fileio fatfs_type_fileio -#define mp_type_textio fatfs_type_textio +#define mp_type_fileio mp_type_vfs_fat_fileio +#define mp_type_textio mp_type_vfs_fat_textio // use vfs's functions for import stat and builtin open #define mp_import_stat mp_vfs_import_stat diff --git a/ports/esp32/mpconfigport.h b/ports/esp32/mpconfigport.h index c7a87e3afe..24034ba16c 100644 --- a/ports/esp32/mpconfigport.h +++ b/ports/esp32/mpconfigport.h @@ -152,8 +152,8 @@ #define MICROPY_FATFS_RPATH (2) #define MICROPY_FATFS_MAX_SS (4096) #define MICROPY_FATFS_LFN_CODE_PAGE (437) /* 1=SFN/ANSI 437=LFN/U.S.(OEM) */ -#define mp_type_fileio fatfs_type_fileio -#define mp_type_textio fatfs_type_textio +#define mp_type_fileio mp_type_vfs_fat_fileio +#define mp_type_textio mp_type_vfs_fat_textio // use vfs's functions for import stat and builtin open #define mp_import_stat mp_vfs_import_stat diff --git a/ports/esp8266/mpconfigport.h b/ports/esp8266/mpconfigport.h index f29dbe5c02..ff45f86aeb 100644 --- a/ports/esp8266/mpconfigport.h +++ b/ports/esp8266/mpconfigport.h @@ -141,8 +141,8 @@ typedef uint32_t sys_prot_t; // for modlwip void *esp_native_code_commit(void*, size_t); #define MP_PLAT_COMMIT_EXEC(buf, len) esp_native_code_commit(buf, len) -#define mp_type_fileio fatfs_type_fileio -#define mp_type_textio fatfs_type_textio +#define mp_type_fileio mp_type_vfs_fat_fileio +#define mp_type_textio mp_type_vfs_fat_textio // use vfs's functions for import stat and builtin open #define mp_import_stat mp_vfs_import_stat diff --git a/ports/stm32/mpconfigport.h b/ports/stm32/mpconfigport.h index 7bd9442131..ecb3596fff 100644 --- a/ports/stm32/mpconfigport.h +++ b/ports/stm32/mpconfigport.h @@ -161,8 +161,8 @@ #define MICROPY_FATFS_MULTI_PARTITION (1) // TODO these should be generic, not bound to fatfs -#define mp_type_fileio fatfs_type_fileio -#define mp_type_textio fatfs_type_textio +#define mp_type_fileio mp_type_vfs_fat_fileio +#define mp_type_textio mp_type_vfs_fat_textio // use vfs's functions for import stat and builtin open #define mp_import_stat mp_vfs_import_stat