more robust import_file path: proper master_directory;
authorwenzelm
Fri, 17 Jan 2025 12:10:59 +0100
changeset 81846 5a7bf0f038e2
parent 81845 acd9849d4e9e
child 81847 c163ad6d18a5
more robust import_file path: proper master_directory; support for compressed proofs.zst (e.g. via "zstd -8");
src/HOL/Import/import_rule.ML
--- a/src/HOL/Import/import_rule.ML	Fri Jan 17 11:49:31 2025 +0100
+++ b/src/HOL/Import/import_rule.ML	Fri Jan 17 12:10:59 2025 +0100
@@ -442,12 +442,16 @@
     process tstate (parse_line str)
   end
 
-fun process_file path thy =
-  #1 (fold process_line (File.read_lines path) (thy, init_state))
+fun process_file path0 thy =
+  let
+    val path = File.absolute_path (Resources.master_directory thy + path0)
+    val lines =
+      if Path.is_zst path then Bytes.read path |> Zstd.uncompress |> Bytes.trim_split_lines
+      else File.read_lines path
+  in #1 (fold process_line lines (thy, init_state)) end
 
 val _ = Outer_Syntax.command \<^command_keyword>\<open>import_file\<close>
   "import a recorded proof file"
   (Parse.path >> (fn name => Toplevel.theory (fn thy => process_file (Path.explode name) thy)))
 
-
 end