@@ -38,10 +38,10 @@ let relpath base path =
38
38
loop (split Filename. dir_sep base) (split Filename. dir_sep path)
39
39
in
40
40
String. concat Filename. dir_sep
41
- ( ( match base = [] with
42
- | true -> [" ." ]
43
- | false -> List. map (fun _ -> " .." ) base )
44
- @ path )
41
+ (( match base = [] with
42
+ | true -> [" ." ]
43
+ | false -> List. map (fun _ -> " .." ) base)
44
+ @ path)
45
45
|> removeExtraDots
46
46
47
47
let maybeStat path =
@@ -57,40 +57,36 @@ let readFile ~filename =
57
57
let content = really_input_string chan (in_channel_length chan) in
58
58
close_in_noerr chan;
59
59
Some content
60
- with
61
- | _ -> None
60
+ with _ -> None
62
61
63
62
let exists path = match maybeStat path with None -> false | Some _ -> true
64
63
65
64
let ifExists path = match exists path with true -> Some path | false -> None
66
65
67
66
let readDirectory dir =
68
- let maybeGet handle =
69
- try Some (Unix. readdir handle) with End_of_file -> None
70
- in
71
- let rec loop handle =
72
- match maybeGet handle with
73
- | None ->
74
- Unix. closedir handle;
75
- []
76
- | Some name
77
- when name = Filename. current_dir_name || name = Filename. parent_dir_name
78
- ->
79
- loop handle
80
- | Some name -> name :: loop handle
81
- in
82
67
match Unix. opendir dir with
83
68
| exception Unix. Unix_error (Unix. ENOENT, "opendir" , _dir ) -> []
84
- | handle -> loop handle
69
+ | handle ->
70
+ let rec loop handle =
71
+ try
72
+ let name = Unix. readdir handle in
73
+ if name = Filename. current_dir_name || name = Filename. parent_dir_name
74
+ then loop handle
75
+ else name :: loop handle
76
+ with End_of_file ->
77
+ Unix. closedir handle;
78
+ []
79
+ in
80
+ loop handle
85
81
86
82
let rec collectDirs path =
87
83
match maybeStat path with
88
84
| None -> []
89
85
| Some {Unix. st_kind = Unix. S_DIR } ->
90
86
path
91
- :: ( readDirectory path
87
+ :: (readDirectory path
92
88
|> List. map (fun name -> collectDirs (Filename. concat path name))
93
- |> List. concat )
89
+ |> List. concat)
94
90
| _ -> []
95
91
96
92
let rec collect ?(checkDir = fun _ -> true ) path test =
@@ -100,10 +96,10 @@ let rec collect ?(checkDir = fun _ -> true) path test =
100
96
if checkDir path then
101
97
readDirectory path
102
98
|> List. map (fun name ->
103
- collect ~check Dir (Filename. concat path name) test)
99
+ collect ~check Dir (Filename. concat path name) test)
104
100
|> List. concat
105
101
else []
106
- | _ -> ( match test path with true -> [path] | false -> [] )
102
+ | _ -> ( match test path with true -> [path] | false -> [] )
107
103
108
104
let fileConcat a b =
109
105
if
0 commit comments