Moves to byte pos counted from the start of the file. Returns false for a closed file or a negative pos.
file_set_position :: (f: File, pos: s64) -> bool
Parameters
- f: File
- pos: s64
Returns
- bool
#import "Extensions/Environment";
base := environment_variable("TMPDIR");
if base == "" base = environment_variable("TEMP");
if base == "" base = "/tmp";
path := tprint("%/jai-doc-set-position.bin", base);
defer file_delete(path);
assert(write_entire_file(path, "abcdef"));
file, ok := file_open(path);
assert(ok);
defer file_close(*file);
assert(file_set_position(file, 4));
rest, rest_ok := read_entire_file(file);
assert(rest_ok && rest == "ef");
free(rest);Doesn't run in the browser (only on windows).