clarified signature: copy directory content more directly;
authorwenzelm
Sun, 11 Dec 2022 14:10:32 +0100
changeset 76621 7af197063e2f
parent 76620 fb322b989584
child 76622 7785ad911416
clarified signature: copy directory content more directly;
src/Pure/Admin/build_prismjs.scala
src/Pure/System/isabelle_system.scala
--- a/src/Pure/Admin/build_prismjs.scala	Sun Dec 11 14:05:12 2022 +0100
+++ b/src/Pure/Admin/build_prismjs.scala	Sun Dec 11 14:10:32 2022 +0100
@@ -36,11 +36,8 @@
     Isabelle_System.with_tmp_dir("tmp") { tmp_dir =>
       Isabelle_System.bash("npm init -y && npm install prismjs@" + Bash.string(version),
         cwd = tmp_dir.file).check
-
-      Isabelle_System.rm_tree(component_dir.path)
       Isabelle_System.copy_dir(tmp_dir + Path.explode("node_modules/prismjs"),
-        component_dir.path)
-      Isabelle_System.make_directory(component_dir.etc)
+        component_dir.path, direct = true)
     }
 
 
--- a/src/Pure/System/isabelle_system.scala	Sun Dec 11 14:05:12 2022 +0100
+++ b/src/Pure/System/isabelle_system.scala	Sun Dec 11 14:10:32 2022 +0100
@@ -162,12 +162,14 @@
     if (path.is_dir) error("Directory already exists: " + path.absolute)
     else make_directory(path)
 
-  def copy_dir(dir1: Path, dir2: Path): Unit = {
+  def copy_dir(dir1: Path, dir2: Path, direct: Boolean = false): Unit = {
     def make_path(dir: Path): String = {
-      File.standard_path(dir.absolute)
+      val s = File.standard_path(dir.absolute)
+      if (direct) Url.direct_path(s) else s
     }
     val p1 = make_path(dir1)
     val p2 = make_path(dir2)
+    if (direct) make_directory(dir2)
     val res = bash("cp -a " + Bash.string(p1) + " " + Bash.string(p2))
     if (!res.ok) cat_error("Failed to copy " + quote(p1) + " to " + quote(p2), res.err)
   }
@@ -188,7 +190,7 @@
 
   object Copy_Dir extends Scala.Fun_Strings("copy_dir") {
     val here = Scala_Project.here
-    def apply(args: List[String]): List[String] = apply_paths2(args, copy_dir)
+    def apply(args: List[String]): List[String] = apply_paths2(args, copy_dir(_, _))
   }