From f12c94e6a8665aa9a7a4572dd65ece4064007f1c Mon Sep 17 00:00:00 2001 From: Son Ho Date: Fri, 4 Mar 2022 00:02:08 +0100 Subject: Update the code to create missing directories upon export --- src/Translate.ml | 6 ++++++ src/dune | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) (limited to 'src') 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 -- cgit v1.2.3