let rm ?(force=Force) ?(recurse=false) fln_lst =
let test_dir =
test (And(Is_dir, Not(Is_link)))
in
let rmdir fn =
try
Unix.rmdir fn
with Unix.Unix_error(Unix.ENOTEMPTY,_,_) ->
raise (RmDirNotEmpty fn)
in
let rec rm_aux lst =
List.iter
(fun fn ->
if test Exists fn && (doit force fn) then
(
if test_dir fn then
(
if recurse then
(
rm_aux (ls fn);
rmdir fn
)
else
(
raise (RmDirNoRecurse fn)
)
)
else
(
Unix.unlink fn
)
)
)
lst
in
rm_aux fln_lst