util.ml 485 B

123456789101112131415161718
  1. let mapjoin f l = (List.fold_left (fun a b -> a ^ (f b)) "" l)
  2. let mapjoine e f = function
  3. [] -> ""
  4. | h::t -> (List.fold_left (fun a b -> a ^ e ^ (f b)) (f h) t)
  5. exception FileAlreadyExists
  6. let open_out_unless_exists path =
  7. if Sys.file_exists path
  8. then raise FileAlreadyExists
  9. else open_out path
  10. let run_in_other_directory tmppath cmd =
  11. let prevdir = Sys.getcwd () in(
  12. Sys.chdir tmppath;
  13. let retval = Sys.command cmd in
  14. (Sys.chdir prevdir; retval)
  15. )