mte/src/fat.ml

47 lines
937 B
OCaml
Raw Normal View History

2026-03-21 07:38:29 +01:00
module Path = struct
let trim_left s =
let s = String.trim s in
if String.starts_with ~prefix:"/" s then String.sub s 1 (String.length s - 1)
else s
let trim_right s =
let s = String.trim s in
if String.ends_with ~suffix:"/" s then String.sub s 0 (String.length s - 1)
else s
let add a b =
let a = trim_right a in
let b = trim_left b in
Fmt.str "%s/%s" a b
(* let ( / ) = add *)
let compare a b = String.compare (trim_right a) (trim_right b)
let equal a b = 0 = compare a b
end
2026-03-11 14:17:52 +01:00
module Fat = Mfat.Make (struct
include Mkernel.Block
let read = atomic_read
let write = atomic_write
end)
include Fat
type entry = Mfat.entry = {
2026-03-21 07:38:29 +01:00
name: string;
2026-03-11 14:17:52 +01:00
is_dir: bool;
size: int32;
}
let create blk =
match Fat.create blk with
| Error (`Msg e) -> Fmt.failwith "FAT file system failure: %s." e
| Ok fs -> fs
type t = Mkernel.Block.t Mfat.t
module type FS = sig
val t : t
end