src/Pure/System/isabelle_system.scala
changeset 76621 7af197063e2f
parent 76620 fb322b989584
child 76623 61dae67ad4dd
equal deleted inserted replaced
76620:fb322b989584 76621:7af197063e2f
   160 
   160 
   161   def new_directory(path: Path): Path =
   161   def new_directory(path: Path): Path =
   162     if (path.is_dir) error("Directory already exists: " + path.absolute)
   162     if (path.is_dir) error("Directory already exists: " + path.absolute)
   163     else make_directory(path)
   163     else make_directory(path)
   164 
   164 
   165   def copy_dir(dir1: Path, dir2: Path): Unit = {
   165   def copy_dir(dir1: Path, dir2: Path, direct: Boolean = false): Unit = {
   166     def make_path(dir: Path): String = {
   166     def make_path(dir: Path): String = {
   167       File.standard_path(dir.absolute)
   167       val s = File.standard_path(dir.absolute)
       
   168       if (direct) Url.direct_path(s) else s
   168     }
   169     }
   169     val p1 = make_path(dir1)
   170     val p1 = make_path(dir1)
   170     val p2 = make_path(dir2)
   171     val p2 = make_path(dir2)
       
   172     if (direct) make_directory(dir2)
   171     val res = bash("cp -a " + Bash.string(p1) + " " + Bash.string(p2))
   173     val res = bash("cp -a " + Bash.string(p1) + " " + Bash.string(p2))
   172     if (!res.ok) cat_error("Failed to copy " + quote(p1) + " to " + quote(p2), res.err)
   174     if (!res.ok) cat_error("Failed to copy " + quote(p1) + " to " + quote(p2), res.err)
   173   }
   175   }
   174 
   176 
   175   def with_copy_dir[A](dir1: Path, dir2: Path)(body: => A): A = {
   177   def with_copy_dir[A](dir1: Path, dir2: Path)(body: => A): A = {
   186     def apply(args: List[String]): List[String] = apply_paths1(args, make_directory)
   188     def apply(args: List[String]): List[String] = apply_paths1(args, make_directory)
   187   }
   189   }
   188 
   190 
   189   object Copy_Dir extends Scala.Fun_Strings("copy_dir") {
   191   object Copy_Dir extends Scala.Fun_Strings("copy_dir") {
   190     val here = Scala_Project.here
   192     val here = Scala_Project.here
   191     def apply(args: List[String]): List[String] = apply_paths2(args, copy_dir)
   193     def apply(args: List[String]): List[String] = apply_paths2(args, copy_dir(_, _))
   192   }
   194   }
   193 
   195 
   194 
   196 
   195   /* copy files */
   197   /* copy files */
   196 
   198