SquashFS compressed filesystem reader in pure OCaml
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

ocaml-squashfs: rewrite README example to typecheck

Top-level [match] joined to a follow-up [match] doesn't parse, and
[Printf.eprintf] / [Format.printf] mixed with the rest. Wrap as
[read_image data = ...], use [Fmt.pr] / [Fmt.epr], add [fmt] to the
mdx libraries.

+14 -18
+13 -17
README.md
··· 44 44 ## Usage 45 45 46 46 ```ocaml 47 - (* Open a SquashFS image *) 48 - let data = "" 49 - match Squashfs.of_string data with 50 - | Error msg -> Printf.eprintf "Error: %s\n" msg 51 - | Ok fs -> 52 - (* Print superblock info *) 53 - Format.printf "%a@." Squashfs.pp_superblock (Squashfs.superblock fs); 54 - 55 - (* List root directory *) 56 - 57 - match Squashfs.readdir fs (Squashfs.root fs) with 58 - | Error msg -> Printf.eprintf "Error: %s\n" msg 59 - | Ok entries -> 60 - List.iter (fun e -> 61 - Format.printf "%s (%a)@." e.Squashfs.name 62 - Squashfs.pp_file_type e.Squashfs.file_type 63 - ) entries 47 + let read_image data = 48 + match Squashfs.of_string data with 49 + | Error msg -> Fmt.epr "Error: %s@." msg 50 + | Ok fs -> ( 51 + Fmt.pr "%a@." Squashfs.pp_superblock (Squashfs.superblock fs); 52 + match Squashfs.readdir fs (Squashfs.root fs) with 53 + | Error msg -> Fmt.epr "Error: %s@." msg 54 + | Ok entries -> 55 + List.iter 56 + (fun e -> 57 + Fmt.pr "%s (%a)@." e.Squashfs.name Squashfs.pp_file_type 58 + e.Squashfs.file_type) 59 + entries) 64 60 ``` 65 61 66 62 ## API
+1 -1
dune
··· 4 4 5 5 (mdx 6 6 (files README.md) 7 - (libraries squashfs)) 7 + (libraries squashfs fmt))