8000 unix: Remove custom file implementation to use extmod's VFS POSIX one. · micropython/micropython@2cdf1d2 · GitHub
[go: up one dir, main page]

Skip to content

Commit 2cdf1d2

Browse files
committed
unix: Remove custom file implementation to use extmod's VFS POSIX one.
The implementation in extmod/vfs_posix_file.c is now equivalent to that in ports/unix/file.c, so remove the latter and use the former instead.
1 parent 68b1bc2 commit 2cdf1d2

File tree

12 files changed

+29
-355
lines changed

12 files changed

+29
-355
lines changed

extmod/vfs_posix_file.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
#include "py/stream.h"
3030
#include "extmod/vfs_posix.h"
3131

32-
#if MICROPY_VFS_POSIX
32+
#if MICROPY_VFS_POSIX || MICROPY_VFS_POSIX_FILE
3333

3434
#include <fcntl.h>
3535

@@ -283,4 +283,4 @@ const mp_obj_vfs_posix_file_t mp_sys_stdin_obj = {{&mp_type_textio}, STDIN_FILEN
283283
const mp_obj_vfs_posix_file_t mp_sys_stdout_obj = {{&mp_type_textio}, STDOUT_FILENO};
284284
const mp_obj_vfs_posix_file_t mp_sys_stderr_obj = {{&mp_type_textio}, STDERR_FILENO};
285285

286-
#endif // MICROPY_VFS_POSIX
286+
#endif // MICROPY_VFS_POSIX || MICROPY_VFS_POSIX_FILE

ports/unix/Makefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,6 @@ SRC_C = \
160160
unix_mphal.c \
161161
mpthreadport.c \
162162
input.c \
163-
file.c \
164163
modmachine.c \
165164
modos.c \
166165
moduos_vfs.c \

ports/unix/fdfile.h

Lines changed: 0 additions & 40 deletions
This file was deleted.

ports/unix/file.c

Lines changed: 0 additions & 305 deletions
This file was deleted.

ports/unix/main.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -717,6 +717,24 @@ uint mp_import_stat(const char *path) {
717717
}
718718
return MP_IMPORT_STAT_NO_EXIST;
719719
}
720+
721+
#if MICROPY_PY_IO
722+
// Factory function for I/O stream classes, only needed if generic VFS subsystem isn't used.
723+
// Note: buffering and encoding are currently ignored.
724+
mp_obj_t mp_builtin_open(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kwargs) {
725+
enum { ARG_file, ARG_mode };
726+
STATIC const mp_arg_t allowed_args[] = {
727+
{ MP_QSTR_file, MP_ARG_OBJ | MP_ARG_REQUIRED, {.u_rom_obj = MP_ROM_NONE} },
728+
{ MP_QSTR_mode, MP_ARG_OBJ, {.u_obj = MP_OBJ_NEW_QSTR(MP_QSTR_r)} },
729+
{ MP_QSTR_buffering, MP_ARG_INT, {.u_int = -1} },
730+
{ MP_QSTR_encoding, MP_ARG_OBJ, {.u_rom_obj = MP_ROM_NONE} },
731+
};
732+
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
733+
mp_arg_parse_all(n_args, pos_args, kwargs, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
734+
return mp_vfs_posix_file_open(&mp_type_textio, args[ARG_file].u_obj, args[ARG_mode].u_obj);
735+
}
736+
MP_DEFINE_CONST_FUN_OBJ_KW(mp_builtin_open_obj, 1, mp_builtin_open);
737+
#endif
720738
#endif
721739

722740
void nlr_jump_fail(void *val) {

0 commit comments

Comments
 (0)
0