diff options
author | Damien George <damien.p.george@gmail.com> | 2014-02-17 22:44:20 +0000 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2014-02-17 22:44:20 +0000 |
commit | 46239413d033a25662700ba39a97b07737b820fc (patch) | |
tree | 910210f2587999e7b563967acf9f1c53a1e24249 | |
parent | 4d0588df561594ed5a4ea16a41251e4dc2e5d0c9 (diff) | |
download | micropython-46239413d033a25662700ba39a97b07737b820fc.tar.gz micropython-46239413d033a25662700ba39a97b07737b820fc.zip |
stm: Implement mp_import_stat.
To follow up pull request #309.
-rw-r--r-- | stm/Makefile | 1 | ||||
-rw-r--r-- | stm/import.c | 20 | ||||
-rw-r--r-- | stm/lexerfatfs.c | 5 |
3 files changed, 21 insertions, 5 deletions
diff --git a/stm/Makefile b/stm/Makefile index 479d93ec7a..e2adddbfd9 100644 --- a/stm/Makefile +++ b/stm/Makefile @@ -49,6 +49,7 @@ SRC_C = \ pendsv.c \ gccollect.c \ lexerfatfs.c \ + import.c \ pyexec.c \ led.c \ gpio.c \ diff --git a/stm/import.c b/stm/import.c new file mode 100644 index 0000000000..3d62c64254 --- /dev/null +++ b/stm/import.c @@ -0,0 +1,20 @@ +#include <stdint.h> + +#include "misc.h" +#include "mpconfig.h" +#include "qstr.h" +#include "lexer.h" +#include "ff.h" + +mp_import_stat_t mp_import_stat(const char *path) { + FILINFO fno; + 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; +} diff --git a/stm/lexerfatfs.c b/stm/lexerfatfs.c index d9eb8a12e0..d1686cb222 100644 --- a/stm/lexerfatfs.c +++ b/stm/lexerfatfs.c @@ -51,8 +51,3 @@ mp_lexer_t *mp_lexer_new_from_file(const char *filename) { fb->pos = 0; return mp_lexer_new(qstr_from_str(filename), fb, (mp_lexer_stream_next_char_t)file_buf_next_char, (mp_lexer_stream_close_t)file_buf_close); } - -mp_import_stat_t mp_import_stat(const char *path) { - // TODO implement me! - return MP_IMPORT_STAT_NO_EXIST; -} |