diff options
| author | Damien George | 2014-02-05 23:57:48 +0000 |
|---|---|---|
| committer | Damien George | 2014-02-05 23:57:48 +0000 |
| commit | e09ffa1400cf4a9283041833fc56b848a87a4c6c (patch) | |
| tree | eff1aa442b8705039aea33cc75075c9171f11593 /unix | |
| parent | cdcb4906d41f42789f6610047e8ae6aa79a61e47 (diff) | |
Search paths properly on import and execute __init__.py if it exists.
Diffstat (limited to 'unix')
| -rw-r--r-- | unix/main.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/unix/main.c b/unix/main.c index d66595cd6..9fb25a43e 100644 --- a/unix/main.c +++ b/unix/main.c @@ -334,3 +334,17 @@ int main(int argc, char **argv) { machine_float_t machine_sqrt(machine_float_t x) { return sqrt(x); } + +#include <sys/stat.h> + +uint mp_import_stat(const char *path) { + struct stat st; + if (stat(path, &st) == 0) { + if (S_ISDIR(st.st_mode)) { + return MP_IMPORT_STAT_DIR; + } else if (S_ISREG(st.st_mode)) { + return MP_IMPORT_STAT_FILE; + } + } + return MP_IMPORT_STAT_NO_EXIST; +} |
