Commits

camlspotter committed fe76d87

comment

  • Participants
  • Parent commits ea32545
  • Branches 4.01.0.2.2.0+win

Comments (0)

Files changed (1)

File filepath.mli

 (* File path normalization *)
 
 type os = 
-  | Unix (** We love *)
-  | Win32 (** We hate *)
-  | Cygwin (** a failed effort of reconcillation *)
+  | Unix   (** We love *)
+  | Win32  (** We hate *)
+  | Cygwin (** A failed effort of reconcillation *)
 
 val os : os
+(** The actual OS the program is running on *)
 
 type t
 
 val is_prefix : t -> t -> string list option
-(** contains_abs /a/b/c /a/b/c/d/e = Some ["d"; "e"] 
+(** [is_prefix a b] checks [a] is a perfix of [b]. 
+
+    For example,
+
+    [is_prefix /a/b/c /a/b/c/d/e = Some ["d"; "e"]] 
+    [is_prefix a/b/c a/b/c/d/e = Some ["d"; "e"]] 
 *)
 
 val of_string : os -> string -> t
+(** Parsing. No normalization performed. *)
+
 val to_string : t -> string
+(** Printing *)
+
+val normalize : t -> t
+(** Normalize the path.
+
+    * Drive name capitalization/uncapitalization
+    * Use backslashes in Win32
+    * Elimination of redundant /./ and /../, if possible.
+*)
 
 val is_absolute : t -> bool
 val is_relative : t -> bool
-(* val root : t *)
 val is_root : t -> bool
+
 val dirbase : t -> t * string option
+(** Split the path into its directory and base parts.
+
+    If the path is the root, it returns None.
+
+    It fails and raises [Invalid_argument "dirbase"],
+    when the path ends with "..".
+*)
+
 val (^/) : t -> string -> t
+(** Concatenation. 
+
+    [t ^/ "hello/world"]
+
+    [t ^/ x] raises [Invalid_argument "(^/)"] when [x] is a string
+    of an absolute path.
+*)
+
 val concats : t -> string list -> t
+(** Concatenation+
+
+    [concats t ["hello"; "world"; "good/bye"]]
+
+    should equal to
+
+    [t ^/ "hello" ^/ "world" ^/ "good" ^/ "bye"]
+
+    It raises [Invalid_argument "(^/)"] when the path components
+    contain an absolute path.
+*) 
+
 val parent : t -> t
+
 val wrap : os -> (t -> t) -> string -> string
 
 val test : unit -> unit