From f6a702538a0b3dd72879d65e3acc32520d4371f5 Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Thu, 10 Aug 2017 15:46:17 -0700 Subject: py: Pretend frozen files are stored under .frozen rather than the empty path. This makes it clear when frozen modules are loaded as opposed to the empty path which represents the current working directory. Furthermore, by splitting the two apart this allows one to control in what order frozen modules are loaded. This is a prerequisite for #56. --- py/builtinimport.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'py/builtinimport.c') diff --git a/py/builtinimport.c b/py/builtinimport.c index 48aee58d1..01dddd02b 100644 --- a/py/builtinimport.c +++ b/py/builtinimport.c @@ -57,9 +57,11 @@ bool mp_obj_is_package(mp_obj_t module) { // (whatever is available, if at all). STATIC mp_import_stat_t mp_import_stat_any(const char *path) { #if MICROPY_MODULE_FROZEN - mp_import_stat_t st = mp_frozen_stat(path); - if (st != MP_IMPORT_STAT_NO_EXIST) { - return st; + if (strlen(path) > 8 && strncmp(".frozen/", path, 8) == 0) { + mp_import_stat_t st = mp_frozen_stat(path + 8); + if (st != MP_IMPORT_STAT_NO_EXIST) { + return st; + } } #endif return mp_import_stat(path); -- cgit v1.2.3