mfat path: keep it simple

This commit is contained in:
swrup 2026-03-21 07:38:29 +01:00 committed by Swrup
parent cbae1c773a
commit ec4e166173
4 changed files with 46 additions and 47 deletions

View file

@ -1,3 +1,24 @@
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
module Fat = Mfat.Make (struct
include Mkernel.Block
@ -5,12 +26,10 @@ module Fat = Mfat.Make (struct
let write = atomic_write
end)
module Sfn = Mfat.Sfn
module Spath = Mfat.Spath
include Fat
type entry = Mfat.entry = {
name: Sfn.t;
name: string;
is_dir: bool;
size: int32;
}