Merge branch 'master' of git@lemon:sqlgg
[sqlgg.git] / filesystem.ml
bloba57d5aa1014dff803d0b03e153431377e961f439
1 (* $Id$ *)
3 let is_dir path = try Some (Sys.is_directory path) with exn -> None
4 let read_dir path = try Sys.readdir path with exn -> [||]
6 let rec of_dir path l =
7 let names = read_dir path in
8 let fullname name = Filename.concat path name in
9 Array.fold_left (fun ll name -> add_entry (fullname name) ll) l names
10 and
11 add_entry path (l1,l2) =
12 match is_dir path with
13 | Some true -> of_dir path (l1,l2)
14 | Some false -> let z1,z2 = xsd_of_file path in (z1@l1),(z2@l2)
15 | None -> l1,l2
17 let norm_path str =
18 let b = (String.starts_with str "/") || (String.starts_with str "\\") in
19 let s = String.strip ~chars:"/\\" str in
20 if b then "\\" ^ s else s