Hello,
The requirement of a Cstruct when I write is not obvious to me. I didn’t come across any examples in the tutorial. I could only put together this after looking at some issues that used this API. The API doc. doesn’t explain this or anything this has to do with io_uring or something like that ?? Can the doc. itself have pieces of code embedded ?
(e.g) eio 0.11 · OCaml Package which has a small piece of example code.
I
let write () =
Eio_main.run @@ fun env ->
let ( / ) = Eio.Path.( / ) in
let path = Eio.Stdenv.fs env in
let p = path / "/Users"/"anu"/"Documents"/"rays"/"Bitcask"/"bitcask"/"bitcask.log" in
let size = if (Sys.file_exists "/Users/anu/Documents/rays/Bitcask/bitcask/bitcask.log") then
(Eio.Path.stat ~follow:true p).size
else Optint.Int63.of_int 0 in
Eio.Path.with_open_out ~create:(`If_missing 0o600) p
(fun f ->
let _ = Eio.File.pwrite_single ~file_offset:size f [Cstruct.create 128] in
()
)
Thanks