summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSon Ho2022-03-04 00:02:08 +0100
committerSon Ho2022-03-04 00:02:08 +0100
commitf12c94e6a8665aa9a7a4572dd65ece4064007f1c (patch)
treee4fecba87b4e0d40e2969befab10d24186c7ad1f /src
parent60a39d180cd7cbf525e8d9f0bd2d5c7855fc73b9 (diff)
Update the code to create missing directories upon export
Diffstat (limited to '')
-rw-r--r--src/Translate.ml6
-rw-r--r--src/dune3
2 files changed, 8 insertions, 1 deletions
diff --git a/src/Translate.ml b/src/Translate.ml
index 1a42892d..5812dc89 100644
--- a/src/Translate.ml
+++ b/src/Translate.ml
@@ -639,6 +639,12 @@ let translate_module (filename : string) (dest_dir : string) (config : config)
}
in
+ (* Create the directory, if necessary *)
+ if not (Sys.file_exists dest_dir) then (
+ log#linfo (lazy ("Creating missing directory: " ^ dest_dir));
+ (* Create a directory with *default* permissions *)
+ Core.Unix.mkdir_p dest_dir);
+
(* Extract one or several files, depending on the configuration *)
if config.split_files then (
let base_gen_config =
diff --git a/src/dune b/src/dune
index 151b2f70..70de366c 100644
--- a/src/dune
+++ b/src/dune
@@ -1,7 +1,8 @@
+;; core: for Core.Unix.mkdir_p
(executable
(name main)
(preprocess (pps ppx_deriving.show ppx_deriving.ord visitors.ppx))
- (libraries ppx_deriving yojson zarith easy_logging))
+ (libraries ppx_deriving yojson zarith easy_logging core))
(env
(dev (flags