Commit 1b9d35dd authored by Tom Niget's avatar Tom Niget

Add context manager functions to file

parent 394e5c18
......@@ -163,7 +163,17 @@ struct {
type(int fd = -1, size_t len = 0) : fd(fd), len(len) {}
type(const type &other)
: fd(other.fd), len(other.len), read(this), close(this) {}
: read(this), write(this), close(this), flush(this), py_enter(this),
py_exit(this), fd(other.fd), len(other.len) {}
METHOD(
type, py_enter, (), const { return *self; })
METHOD(
typon::Task<bool>, py_exit, (), const {
co_await self->close();
co_return true;
})
int fd;
size_t len;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment