Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
TASTE
uPython-mirror
Commits
122c9db3
Commit
122c9db3
authored
Jul 13, 2014
by
Paul Sokolovsky
Browse files
unix: file: Implement .flush() method.
This method apparently should be part of stream interface.
parent
a1760a56
Changes
2
Hide whitespace changes
Inline
Side-by-side
unix/file.c
View file @
122c9db3
...
...
@@ -82,6 +82,13 @@ STATIC mp_int_t fdfile_write(mp_obj_t o_in, const void *buf, mp_uint_t size, int
return
r
;
}
STATIC
mp_obj_t
fdfile_flush
(
mp_obj_t
self_in
)
{
mp_obj_fdfile_t
*
self
=
self_in
;
fsync
(
self
->
fd
);
return
mp_const_none
;
}
STATIC
MP_DEFINE_CONST_FUN_OBJ_1
(
fdfile_flush_obj
,
fdfile_flush
);
STATIC
mp_obj_t
fdfile_close
(
mp_obj_t
self_in
)
{
mp_obj_fdfile_t
*
self
=
self_in
;
close
(
self
->
fd
);
...
...
@@ -166,6 +173,7 @@ STATIC const mp_map_elem_t rawfile_locals_dict_table[] = {
{
MP_OBJ_NEW_QSTR
(
MP_QSTR_readline
),
(
mp_obj_t
)
&
mp_stream_unbuffered_readline_obj
},
{
MP_OBJ_NEW_QSTR
(
MP_QSTR_readlines
),
(
mp_obj_t
)
&
mp_stream_unbuffered_readlines_obj
},
{
MP_OBJ_NEW_QSTR
(
MP_QSTR_write
),
(
mp_obj_t
)
&
mp_stream_write_obj
},
{
MP_OBJ_NEW_QSTR
(
MP_QSTR_flush
),
(
mp_obj_t
)
&
fdfile_flush_obj
},
{
MP_OBJ_NEW_QSTR
(
MP_QSTR_close
),
(
mp_obj_t
)
&
fdfile_close_obj
},
{
MP_OBJ_NEW_QSTR
(
MP_QSTR___enter__
),
(
mp_obj_t
)
&
mp_identity_obj
},
{
MP_OBJ_NEW_QSTR
(
MP_QSTR___exit__
),
(
mp_obj_t
)
&
fdfile___exit___obj
},
...
...
unix/qstrdefsport.h
View file @
122c9db3
...
...
@@ -32,6 +32,7 @@ Q(fileno)
Q
(
makefile
)
Q
(
FileIO
)
Q
(
flush
)
Q
(
_os
)
Q
(
stat
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment