package fat-filesystem

  1. Overview
  2. Docs
type datetime = {
  1. year : int;
  2. month : int;
  3. day : int;
  4. hours : int;
  5. mins : int;
  6. secs : int;
  7. ms : int;
}
val epoch : datetime
type lfn = {
  1. lfn_deleted : bool;
  2. lfn_last : bool;
    (*

    marks the highest sequence number

    *)
  3. lfn_seq : int;
  4. lfn_checksum : int;
  5. lfn_utf16_name : string;
}

Long filename entry: the same size as an original DOS disk entry

type dos = {
  1. filename : string;
    (*

    8 chars

    *)
  2. ext : string;
    (*

    3 chars

    *)
  3. deleted : bool;
  4. read_only : bool;
  5. hidden : bool;
  6. system : bool;
  7. volume : bool;
  8. subdir : bool;
  9. archive : bool;
  10. create : datetime;
  11. access : datetime;
  12. modify : datetime;
  13. start_cluster : int;
  14. file_size : int32;
}

A DOS disk entry

type single_entry =
  1. | Dos of dos
  2. | Lfn of lfn
  3. | End
    (*

    Useful for streaming entries to/from the disk

    *)
type r = {
  1. utf_filename : string;
  2. dos : int * dos;
  3. lfns : (int * lfn) list;
}

A high-level directory entry, complete with reconstructed UTF name and offsets of each individual entry on the disk

val fake_root_entry : r
val file_size_of : r -> int32
val deleted : r -> bool
val filename_of : r -> string
val to_single_entries : r -> single_entry list
val dos_name_of_filename : string -> string * string
val compute_checksum : dos -> int

Returns the checksum corresponding to the 8.3 DOS filename

val make : ?read_only:bool -> ?system:bool -> ?subdir:bool -> string -> r
val to_string : r -> string

to_string r returns a canonical version of the name in UTF-8

val to_pretty_string : r -> string

to_pretty_string r returns a pretty version of the filename, containing both legacy DOS, extra UTF16, size and time components.

val int_to_hms : int -> int * int * int
val hms_to_int : (int * int * int) -> int
val int_of_time : datetime -> int
val time_of_int : int -> int -> int -> datetime
val int_of_date : datetime -> int
val unmarshal : Cstruct.t -> single_entry

unmarshal slot parses a single directory entry from slot

val marshal : Cstruct.t -> single_entry -> unit

marshal slot single_entry writes single_entry into slot

val sizeof : int

the size in bytes of a single_entry

val blocks : Cstruct.t -> (int * Cstruct.t) list

blocks bits returns the directory chopped into individual bitstrings, each one containing a possible name (fragment)

val fold : ('a -> int -> r -> 'a) -> 'a -> Cstruct.t -> 'a

fold f initial bits folds f acc offset dir_entry across all the reconstructed directory entries contained in bits.

val list : Cstruct.t -> r list

list bits returns a list of valid (not deleted) directory entries contained within the directory bits

val next : Cstruct.t -> int option

next bits returns the bit offset of a free directory slot. Note this function does not recycle deleted elements.

val add : Cstruct.t -> r -> Fat_update.t list

add block t return the update required to add t to the directory block. Note the update may be beyond the end of block indicating more space needs to be allocated.

val name_match : string -> r -> bool
val find : string -> r list -> r option

find name list returns Some d where d is a name with name name (or None)

val remove : Cstruct.t -> string -> Fat_update.t list

remove buf filename erases any entries corresponding to filename from buf

val modify : Cstruct.t -> string -> int32 -> int -> Fat_update.t list

modify buf filename file_size start_cluster changes any entry corresponding to filename in buf to have file_size and start_cluster

OCaml

Innovation. Community. Security.