add result.ml; polymorphic variant errors + refacto

This commit is contained in:
swrup 2026-03-26 06:23:42 +01:00 committed by Swrup
parent 9fd3b5a3cc
commit 42b0ec1445
36 changed files with 949 additions and 954 deletions

View file

@ -19,6 +19,14 @@ module Path = struct
let equal a b = 0 = compare a b
end
type t = Mkernel.Block.t Mfat.t
type entry = Mfat.entry = {
name: string;
is_dir: bool;
size: int32;
}
module Fat = Mfat.Make (struct
include Mkernel.Block
@ -28,18 +36,21 @@ end)
include Fat
type entry = Mfat.entry = {
name: string;
is_dir: bool;
size: int32;
}
let create blk =
match Fat.create blk with
| Error (`Msg e) -> Fmt.failwith "FAT file system failure: %s." e
match create blk with
| Error (`Msg e) ->
Fmt.epr "FAT file system initialization failure: %s@." e;
exit 1
| Ok fs -> fs
type t = Mkernel.Block.t Mfat.t
let map_err r = Result.map_error (fun (`Msg e) -> `Mfat e) r
let ls t p = ls t p |> map_err
let read t p = read t p |> map_err
let write t p s = write t p s |> map_err
let mkdir t p = mkdir t p |> map_err
let remove t p = remove t p |> map_err
let exists t p = exists t p
let stat t p = stat t p |> map_err
module type FS = sig
val t : t