code_target: create subdirectories for export_code file
authorstuebinm <stuebinm@disroot.org>
Tue, 04 Apr 2023 16:06:12 +0200
changeset 77859 a11e25bdd247
parent 77852 df35b5b7b6a4
child 77860 21bb32a7fd58
code_target: create subdirectories for export_code file
src/Tools/Code/code_target.ML
--- a/src/Tools/Code/code_target.ML	Fri Apr 14 22:55:01 2023 +0200
+++ b/src/Tools/Code/code_target.ML	Tue Apr 04 16:06:12 2023 +0200
@@ -311,9 +311,14 @@
   (case pretty_modules of
     Singleton (_, p) => Bytes.write root (format p)
   | Hierarchy code_modules =>
-      (Isabelle_System.make_directory root;
-        List.app (fn (names, p) =>
-          Bytes.write (Path.appends (root :: map Path.basic names)) (format p)) code_modules));
+     List.app (fn (names, p) =>
+       let
+         val segments = map Path.basic names;
+       in
+         Isabelle_System.make_directory (Path.appends (root :: (fst (split_last segments))));
+         Bytes.write (Path.appends (root :: segments)) (format p)
+       end)
+     code_modules);
 
 in