diff --git a/src/io.cpp b/src/io.cpp index b5cb9432..172f6815 100644 --- a/src/io.cpp +++ b/src/io.cpp @@ -67,6 +67,14 @@ unsigned char* _default_import_handler(const char* name_p, int name_size, int* o return VAR(std::move(b)); }); + vm->bind_method<1>(type, "seek", [](VM* vm, ArgsView args){ + FileIO& io = CAST(FileIO&, args[0]); + size_t newpos = CAST(size_t, args[1]); + if (!fseek(io.fp, newpos, SEEK_SET)) + return vm->True; + return vm->False; + }); + vm->bind_method<1>(type, "write", [](VM* vm, ArgsView args){ FileIO& io = CAST(FileIO&, args[0]); if(io.is_text()){ @@ -203,4 +211,4 @@ void add_module_os(VM* vm){ #endif } -} // namespace pkpy \ No newline at end of file +} // namespace pkpy