diff options
author | Damien George <damien.p.george@gmail.com> | 2016-06-01 17:00:28 +0100 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2017-01-27 13:19:10 +1100 |
commit | f5f4cdae89ed040ae9209a380cf968254434e819 (patch) | |
tree | 6496e5939c3233091e00827939393cd112a9f385 /extmod/vfs_fat_reader.c | |
parent | d4464b005093ffbc0f5ff8ec736927a46e7926ca (diff) |
extmod/vfs_fat: Rework so it can optionally use OO version of FatFS.
If MICROPY_VFS_FAT is enabled by a port then the port must switch to using
MICROPY_FATFS_OO. Otherwise a port can continue to use the FatFs code
without any changes.
Diffstat (limited to 'extmod/vfs_fat_reader.c')
-rw-r--r-- | extmod/vfs_fat_reader.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/extmod/vfs_fat_reader.c b/extmod/vfs_fat_reader.c index 7a00f18de..efd2de0c1 100644 --- a/extmod/vfs_fat_reader.c +++ b/extmod/vfs_fat_reader.c @@ -32,7 +32,12 @@ #if MICROPY_READER_FATFS +#if MICROPY_FATFS_OO +#include "lib/oofatfs/ff.h" +#else #include "lib/fatfs/ff.h" +#endif +#include "extmod/fsusermount.h" #include "extmod/vfs_fat_file.h" typedef struct _mp_reader_fatfs_t { @@ -71,7 +76,15 @@ int mp_reader_new_file(mp_reader_t *reader, const char *filename) { if (rf == NULL) { return MP_ENOMEM; } + #if MICROPY_FATFS_OO + fs_user_mount_t *vfs = ff_get_vfs(&filename); + if (vfs == NULL) { + return MP_ENOENT; + } + FRESULT res = f_open(&vfs->fatfs, &rf->fp, filename, FA_READ); + #else FRESULT res = f_open(&rf->fp, filename, FA_READ); + #endif if (res != FR_OK) { return fresult_to_errno_table[res]; } |