mirror of
https://github.com/pocketpy/pocketpy
synced 2025-11-10 05:30:16 +00:00
add FileIO.seek internal to seek in current file, returns True on success
This commit is contained in:
parent
6fea4fed87
commit
46f519bdb8
@ -67,6 +67,14 @@ unsigned char* _default_import_handler(const char* name_p, int name_size, int* o
|
|||||||
return VAR(std::move(b));
|
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){
|
vm->bind_method<1>(type, "write", [](VM* vm, ArgsView args){
|
||||||
FileIO& io = CAST(FileIO&, args[0]);
|
FileIO& io = CAST(FileIO&, args[0]);
|
||||||
if(io.is_text()){
|
if(io.is_text()){
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user