summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--extmod/vfs_posix.c13
-rw-r--r--ports/windows/Makefile1
-rw-r--r--ports/windows/micropython.vcxproj1
-rw-r--r--ports/windows/mpconfigport.h16
-rw-r--r--ports/windows/msvc/sources.props4
-rw-r--r--py/mpconfig.h4
6 files changed, 34 insertions, 5 deletions
diff --git a/extmod/vfs_posix.c b/extmod/vfs_posix.c
index 719afe28f..5dcc9c03e 100644
--- a/extmod/vfs_posix.c
+++ b/extmod/vfs_posix.c
@@ -37,6 +37,9 @@
#include <string.h>
#include <sys/stat.h>
#include <dirent.h>
+#ifdef _MSC_VER
+#include <direct.h> // For mkdir etc.
+#endif
typedef struct _mp_obj_vfs_posix_t {
mp_obj_base_t base;
@@ -254,7 +257,11 @@ STATIC mp_obj_t vfs_posix_mkdir(mp_obj_t self_in, mp_obj_t path_in) {
mp_obj_vfs_posix_t *self = MP_OBJ_TO_PTR(self_in);
const char *path = vfs_posix_get_path_str(self, path_in);
MP_THREAD_GIL_EXIT();
+ #ifdef _WIN32
+ int ret = mkdir(path);
+ #else
int ret = mkdir(path, 0777);
+ #endif
MP_THREAD_GIL_ENTER();
if (ret != 0) {
mp_raise_OSError(errno);
@@ -308,6 +315,8 @@ STATIC mp_obj_t vfs_posix_stat(mp_obj_t self_in, mp_obj_t path_in) {
}
STATIC MP_DEFINE_CONST_FUN_OBJ_2(vfs_posix_stat_obj, vfs_posix_stat);
+#if MICROPY_PY_UOS_STATVFS
+
#ifdef __ANDROID__
#define USE_STATFS 1
#endif
@@ -349,6 +358,8 @@ STATIC mp_obj_t vfs_posix_statvfs(mp_obj_t self_in, mp_obj_t path_in) {
}
STATIC MP_DEFINE_CONST_FUN_OBJ_2(vfs_posix_statvfs_obj, vfs_posix_statvfs);
+#endif
+
STATIC const mp_rom_map_elem_t vfs_posix_locals_dict_table[] = {
{ MP_ROM_QSTR(MP_QSTR_mount), MP_ROM_PTR(&vfs_posix_mount_obj) },
{ MP_ROM_QSTR(MP_QSTR_umount), MP_ROM_PTR(&vfs_posix_umount_obj) },
@@ -362,7 +373,9 @@ STATIC const mp_rom_map_elem_t vfs_posix_locals_dict_table[] = {
{ MP_ROM_QSTR(MP_QSTR_rename), MP_ROM_PTR(&vfs_posix_rename_obj) },
{ MP_ROM_QSTR(MP_QSTR_rmdir), MP_ROM_PTR(&vfs_posix_rmdir_obj) },
{ MP_ROM_QSTR(MP_QSTR_stat), MP_ROM_PTR(&vfs_posix_stat_obj) },
+ #if MICROPY_PY_UOS_STATVFS
{ MP_ROM_QSTR(MP_QSTR_statvfs), MP_ROM_PTR(&vfs_posix_statvfs_obj) },
+ #endif
};
STATIC MP_DEFINE_CONST_DICT(vfs_posix_locals_dict, vfs_posix_locals_dict_table);
diff --git a/ports/windows/Makefile b/ports/windows/Makefile
index 91744b7a5..c9efc2353 100644
--- a/ports/windows/Makefile
+++ b/ports/windows/Makefile
@@ -49,7 +49,6 @@ SRC_C = \
shared/runtime/gchelper_generic.c \
ports/unix/main.c \
ports/unix/input.c \
- ports/unix/modos.c \
ports/unix/modmachine.c \
ports/unix/modtime.c \
ports/unix/gccollect.c \
diff --git a/ports/windows/micropython.vcxproj b/ports/windows/micropython.vcxproj
index d5e3f57d8..4fa0c47df 100644
--- a/ports/windows/micropython.vcxproj
+++ b/ports/windows/micropython.vcxproj
@@ -93,7 +93,6 @@
<ClCompile Include="$(PyBaseDir)ports\unix\gccollect.c"/>
<ClCompile Include="$(PyBaseDir)ports\unix\input.c"/>
<ClCompile Include="$(PyBaseDir)ports\unix\main.c"/>
- <ClCompile Include="$(PyBaseDir)ports\unix\modos.c"/>
<ClCompile Include="$(PyBaseDir)ports\unix\modtime.c"/>
<ClCompile Include="$(PyBaseDir)ports\unix\modmachine.c" />
<ClCompile Include="$(PyVariantDir)*.c" />
diff --git a/ports/windows/mpconfigport.h b/ports/windows/mpconfigport.h
index d589dac7a..4679d1356 100644
--- a/ports/windows/mpconfigport.h
+++ b/ports/windows/mpconfigport.h
@@ -51,6 +51,7 @@
#define MICROPY_DEBUG_PRINTER (&mp_stderr_print)
#define MICROPY_DEBUG_PRINTERS (1)
#define MICROPY_READER_POSIX (1)
+#define MICROPY_READER_VFS (1)
#define MICROPY_USE_READLINE_HISTORY (1)
#define MICROPY_HELPER_REPL (1)
#define MICROPY_REPL_EMACS_KEYS (1)
@@ -72,7 +73,8 @@
#ifndef MICROPY_ENABLE_SCHEDULER
#define MICROPY_ENABLE_SCHEDULER (1)
#endif
-#define MICROPY_VFS_POSIX_FILE (1)
+#define MICROPY_VFS (1)
+#define MICROPY_VFS_POSIX (1)
#define MICROPY_PY_FUNCTION_ATTRS (1)
#define MICROPY_PY_DESCRIPTORS (1)
#define MICROPY_PY_DELATTR_SETATTR (1)
@@ -124,6 +126,14 @@
#define MICROPY_STACKLESS_STRICT (0)
#endif
+#define MICROPY_PY_UOS (1)
+#define MICROPY_PY_UOS_INCLUDEFILE "ports/unix/moduos.c"
+#define MICROPY_PY_UOS_ERRNO (1)
+#define MICROPY_PY_UOS_GETENV_PUTENV_UNSETENV (1)
+#define MICROPY_PY_UOS_SEP (1)
+#define MICROPY_PY_UOS_STATVFS (0)
+#define MICROPY_PY_UOS_SYSTEM (1)
+#define MICROPY_PY_UOS_URANDOM (1)
#define MICROPY_PY_UTIME (1)
#define MICROPY_PY_UTIME_MP_HAL (1)
#define MICROPY_PY_UERRNO (1)
@@ -161,6 +171,8 @@ extern const struct _mp_print_t mp_stderr_print;
#define MICROPY_EMERGENCY_EXCEPTION_BUF_SIZE (256)
#define MICROPY_KBD_EXCEPTION (1)
+#define mp_import_stat mp_vfs_import_stat
+#define mp_builtin_open_obj mp_vfs_open_obj
#define mp_type_fileio mp_type_vfs_posix_fileio
#define mp_type_textio mp_type_vfs_posix_textio
@@ -203,11 +215,9 @@ typedef long mp_off_t;
#define MICROPY_PORT_BUILTINS \
{ MP_ROM_QSTR(MP_QSTR_open), MP_ROM_PTR(&mp_builtin_open_obj) },
-extern const struct _mp_obj_module_t mp_module_os;
extern const struct _mp_obj_module_t mp_module_time;
#define MICROPY_PORT_BUILTIN_MODULES \
{ MP_ROM_QSTR(MP_QSTR_utime), MP_ROM_PTR(&mp_module_time) }, \
- { MP_ROM_QSTR(MP_QSTR_uos), MP_ROM_PTR(&mp_module_os) }, \
#if MICROPY_USE_READLINE == 1
#define MICROPY_PORT_ROOT_POINTERS \
diff --git a/ports/windows/msvc/sources.props b/ports/windows/msvc/sources.props
index a6dfd48aa..b755049db 100644
--- a/ports/windows/msvc/sources.props
+++ b/ports/windows/msvc/sources.props
@@ -13,6 +13,7 @@
<PyExtModSource Include="$(PyBaseDir)extmod\moduhashlib.c" />
<PyExtModSource Include="$(PyBaseDir)extmod\moduheapq.c" />
<PyExtModSource Include="$(PyBaseDir)extmod\modujson.c" />
+ <PyExtModSource Include="$(PyBaseDir)extmod\moduos.c" />
<PyExtModSource Include="$(PyBaseDir)extmod\modurandom.c" />
<PyExtModSource Include="$(PyBaseDir)extmod\modure.c" />
<PyExtModSource Include="$(PyBaseDir)extmod\moduselect.c" />
@@ -20,7 +21,10 @@
<PyExtModSource Include="$(PyBaseDir)extmod\moduzlib.c" />
<PyExtModSource Include="$(PyBaseDir)extmod\utime_mphal.c" />
<PyExtModSource Include="$(PyBaseDir)extmod\virtpin.c" />
+ <PyExtModSource Include="$(PyBaseDir)extmod\vfs.c" />
+ <PyExtModSource Include="$(PyBaseDir)extmod\vfs_posix.c" />
<PyExtModSource Include="$(PyBaseDir)extmod\vfs_posix_file.c" />
+ <PyExtModSource Include="$(PyBaseDir)extmod\vfs_reader.c" />
</ItemGroup>
<ItemGroup>
<PyCoreInclude Include="$(PyBaseDir)py\*.h" />
diff --git a/py/mpconfig.h b/py/mpconfig.h
index 8f9f0f02f..a41e99b4c 100644
--- a/py/mpconfig.h
+++ b/py/mpconfig.h
@@ -1459,6 +1459,10 @@ typedef double mp_float_t;
#define MICROPY_PY_UOS (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
#endif
+#ifndef MICROPY_PY_UOS_STATVFS
+#define MICROPY_PY_UOS_STATVFS (MICROPY_PY_UOS)
+#endif
+
#ifndef MICROPY_PY_URE
#define MICROPY_PY_URE (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
#endif