more checks;
authorwenzelm
Sat, 27 Feb 2021 13:39:06 +0100
changeset 73312 736b8853189a
parent 73311 54262af6d310
child 73313 8ae2f8ebc373
more checks;
src/Pure/PIDE/resources.ML
src/Pure/Pure.thy
--- a/src/Pure/PIDE/resources.ML	Sat Feb 27 13:37:04 2021 +0100
+++ b/src/Pure/PIDE/resources.ML	Sat Feb 27 13:39:06 2021 +0100
@@ -48,6 +48,7 @@
   val check_path: Proof.context -> Path.T option -> Input.source -> Path.T
   val check_file: Proof.context -> Path.T option -> Input.source -> Path.T
   val check_dir: Proof.context -> Path.T option -> Input.source -> Path.T
+  val check_session_dir: Proof.context -> Path.T option -> Input.source -> Path.T
 end;
 
 structure Resources: RESOURCES =
@@ -387,6 +388,19 @@
 val check_file = formal_check File.check_file;
 val check_dir = formal_check File.check_dir;
 
+fun check_session_dir ctxt opt_dir s =
+  let
+    val dir = Path.expand (check_dir ctxt opt_dir s);
+    val ok =
+      File.is_file (dir + Path.explode("ROOT")) orelse
+      File.is_file (dir + Path.explode("ROOTS"));
+  in
+    if ok then dir
+    else
+      error ("Bad session root directory (missing ROOT or ROOTS): " ^
+        Path.print dir ^ Position.here (Input.pos_of s))
+  end;
+
 
 (* antiquotations *)
 
--- a/src/Pure/Pure.thy	Sat Feb 27 13:37:04 2021 +0100
+++ b/src/Pure/Pure.thy	Sat Feb 27 13:39:06 2021 +0100
@@ -136,12 +136,13 @@
                 let
                   val pos2 = pos1 |> fold Position.advance (Symbol.explode line);
                   val range = Position.range (pos1, pos2);
+                  val source = Input.source true line range;
                   val _ =
                     if line = "" then ()
                     else if String.isPrefix "#" line then
                       Context_Position.report ctxt (#1 range) Markup.comment
                     else
-                      (ignore (Resources.check_dir ctxt (SOME dir) (Input.source true line range))
+                      (ignore (Resources.check_session_dir ctxt (SOME dir) source)
                         handle ERROR msg => Output.error_message msg);
                 in pos2 |> Position.advance "\n" end);
           in thy' end)));