package zipc

  1. Overview
  2. Docs

File paths and modes.

File paths

type t = string

The type for file paths. Note that this may be the empty string.

val ensure_unix : t -> t

ensure_unix p substitutes any '\\' by '/' in p.

val ensure_directoryness : t -> t

ensure_directoryness p makes sure p ends with a '/'. Returns "./" on the empty string.

val sanitize : t -> t

sanitize_path p is a sanitized for path p. This is either a relative path rooted in the current directory or the empty string. Directoryness (trailing '/') is suppressed and the function is not injective.

No effort is made to interpret relative segments correctly; a zip file with such paths is likely malice or clumsiness. More precisely this splits p on '/' and '\\', removes any ".", ".." or "" segment (in particular this removes absolute paths) and concatenates the resulting list with "/".

File modes

type mode = int

The type for UNIX file modes.

val pp_mode : Format.formatter -> int -> unit

pp_mode formats file modes like ls -l does.

OCaml

Innovation. Community. Security.