let find_in paths path =
let rec aux = function
- | [] -> raise (Failure "not found")
+ | [] -> raise (Failure "find_in")
| p :: tl ->
let path = normalize_path (p ^ "/" ^ path) in
try
aux paths
with Unix.Unix_error _ | Failure _ ->
raise
- (Failure ("File " ^ path ^ " not found (or not readable) in: " ^
- String.concat ":" paths))
+ (Failure "find_in")
;;
+let is_prefix_of d1 d2 =
+ let len1 = String.length d1 in
+ let len2 = String.length d2 in
+ if len2 < len1 then
+ false
+ else
+ let pref = String.sub d2 0 len1 in
+ pref = d1 && (len1 = len2 || d2.[len1] = '/')
+;;
+
+let touch s =
+ try close_out(open_out s) with Sys_error _ -> ()
+;;