more operations (as in Isabelle/ML);
authorwenzelm
Wed, 11 Nov 2020 20:55:25 +0100
changeset 72572 e7e93c0f6d96
parent 72571 ab4a0b19648a
child 72573 a085a1a89388
more operations (as in Isabelle/ML);
src/Pure/General/file.scala
src/Pure/General/path.scala
--- a/src/Pure/General/file.scala	Tue Nov 10 12:48:56 2020 +0100
+++ b/src/Pure/General/file.scala	Wed Nov 11 20:55:25 2020 +0100
@@ -323,6 +323,14 @@
 
   def copy(path1: Path, path2: Path): Unit = copy(path1.file, path2.file)
 
+  def copy_base(base_dir: Path, src0: Path, target_dir: Path)
+  {
+    val src = src0.expand
+    val src_dir = src.dir
+    if (!src.starts_basic) error("Illegal path specification " + src + " beyond base directory")
+    copy(base_dir + src, Isabelle_System.make_directory(target_dir + src_dir))
+  }
+
 
   /* move */
 
--- a/src/Pure/General/path.scala	Tue Nov 10 12:48:56 2020 +0100
+++ b/src/Pure/General/path.scala	Wed Nov 11 20:55:25 2020 +0100
@@ -156,6 +156,7 @@
   def is_absolute: Boolean = elems.nonEmpty && elems.last.isInstanceOf[Path.Root]
   def is_root: Boolean = elems match { case List(Path.Root(_)) => true case _ => false }
   def is_basic: Boolean = elems match { case List(Path.Basic(_)) => true case _ => false }
+  def starts_basic: Boolean = elems.nonEmpty && elems.last.isInstanceOf[Path.Basic]
 
   def +(other: Path): Path = new Path((other.elems :\ elems)(Path.apply_elem))