Test-case (creates "/data", deletes it, then lists "/"):
open Lwt
module F = Fat.Fs.Make(Block)(Io_page)
let (>>|=) x f = x >>= function
| `Error e -> failwith (Fat.Fs.string_of_filesystem_error e)
| `Ok v -> f v
let main =
Block.connect "disk.img" >>= function
| `Error (`Unknown msg) -> failwith msg
| `Error _ -> failwith "Block error"
| `Ok block ->
F.connect block >>|= fun fs ->
F.format fs 0x100000L >>|= fun () ->
F.create fs "/data" >>|= fun () ->
F.destroy fs "/data" >>|= fun () ->
F.listdir fs "/" >>|= fun items ->
List.iter (Printf.printf "Item: %s\n") items;
print_endline "Done listing.";
return ()
let () = Lwt_unix.run main
Test-case (creates "/data", deletes it, then lists "/"):
This outputs: