diff options
Diffstat (limited to 'unix/main.c')
-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 d66595cd66..9fb25a43e2 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; +} |