src/Pure/System/isabelle_system.scala
changeset 73567 355af2d1b817
parent 73566 4e6b31ed7197
child 73573 a30a60aef59f
equal deleted inserted replaced
73566:4e6b31ed7197 73567:355af2d1b817
   225 
   225 
   226   /** file-system operations **/
   226   /** file-system operations **/
   227 
   227 
   228   /* scala functions */
   228   /* scala functions */
   229 
   229 
   230   private def apply_paths(arg: String, fun: List[Path] => Unit): String =
   230   private def apply_paths(args: List[String], fun: List[Path] => Unit): List[String] =
   231     { fun(Library.split_strings0(arg).map(Path.explode)); "" }
   231     { fun(args.map(Path.explode)); Nil }
   232 
   232 
   233   private def apply_paths1(arg: String, fun: Path => Unit): String =
   233   private def apply_paths1(args: List[String], fun: Path => Unit): List[String] =
   234     apply_paths(arg, { case List(path) => fun(path) })
   234     apply_paths(args, { case List(path) => fun(path) })
   235 
   235 
   236   private def apply_paths2(arg: String, fun: (Path, Path) => Unit): String =
   236   private def apply_paths2(args: List[String], fun: (Path, Path) => Unit): List[String] =
   237     apply_paths(arg, { case List(path1, path2) => fun(path1, path2) })
   237     apply_paths(args, { case List(path1, path2) => fun(path1, path2) })
   238 
   238 
   239   private def apply_paths3(arg: String, fun: (Path, Path, Path) => Unit): String =
   239   private def apply_paths3(args: List[String], fun: (Path, Path, Path) => Unit): List[String] =
   240     apply_paths(arg, { case List(path1, path2, path3) => fun(path1, path2, path3) })
   240     apply_paths(args, { case List(path1, path2, path3) => fun(path1, path2, path3) })
   241 
   241 
   242 
   242 
   243   /* permissions */
   243   /* permissions */
   244 
   244 
   245   def chmod(arg: String, path: Path): Unit =
   245   def chmod(arg: String, path: Path): Unit =
   271       cat_error("Failed to copy directory " + dir1.absolute + " to " + dir2.absolute, res.err)
   271       cat_error("Failed to copy directory " + dir1.absolute + " to " + dir2.absolute, res.err)
   272     }
   272     }
   273   }
   273   }
   274 
   274 
   275 
   275 
   276   object Make_Directory extends Scala.Fun_String("make_directory")
   276   object Make_Directory extends Scala.Fun_Strings("make_directory")
   277   {
   277   {
   278     val here = Scala_Project.here
   278     val here = Scala_Project.here
   279     def apply(arg: String): String = apply_paths1(arg, make_directory)
   279     def apply(args: List[String]): List[String] = apply_paths1(args, make_directory)
   280   }
   280   }
   281 
   281 
   282   object Copy_Dir extends Scala.Fun_String("copy_dir")
   282   object Copy_Dir extends Scala.Fun_Strings("copy_dir")
   283   {
   283   {
   284     val here = Scala_Project.here
   284     val here = Scala_Project.here
   285     def apply(arg: String): String = apply_paths2(arg, copy_dir)
   285     def apply(args: List[String]): List[String] = apply_paths2(args, copy_dir)
   286   }
   286   }
   287 
   287 
   288 
   288 
   289   /* copy files */
   289   /* copy files */
   290 
   290 
   314     if (!src1.starts_basic) error("Illegal path specification " + src1 + " beyond base directory")
   314     if (!src1.starts_basic) error("Illegal path specification " + src1 + " beyond base directory")
   315     copy_file(base_dir + src1, Isabelle_System.make_directory(target_dir + src1_dir))
   315     copy_file(base_dir + src1, Isabelle_System.make_directory(target_dir + src1_dir))
   316   }
   316   }
   317 
   317 
   318 
   318 
   319   object Copy_File extends Scala.Fun_String("copy_file")
   319   object Copy_File extends Scala.Fun_Strings("copy_file")
   320   {
   320   {
   321     val here = Scala_Project.here
   321     val here = Scala_Project.here
   322     def apply(arg: String): String = apply_paths2(arg, copy_file)
   322     def apply(args: List[String]): List[String] = apply_paths2(args, copy_file)
   323   }
   323   }
   324 
   324 
   325   object Copy_File_Base extends Scala.Fun_String("copy_file_base")
   325   object Copy_File_Base extends Scala.Fun_Strings("copy_file_base")
   326   {
   326   {
   327     val here = Scala_Project.here
   327     val here = Scala_Project.here
   328     def apply(arg: String): String = apply_paths3(arg, copy_file_base)
   328     def apply(args: List[String]): List[String] = apply_paths3(args, copy_file_base)
   329   }
   329   }
   330 
   330 
   331 
   331 
   332   /* move files */
   332   /* move files */
   333 
   333 
   414     }
   414     }
   415   }
   415   }
   416 
   416 
   417   def rm_tree(root: Path): Unit = rm_tree(root.file)
   417   def rm_tree(root: Path): Unit = rm_tree(root.file)
   418 
   418 
   419   object Rm_Tree extends Scala.Fun_String("rm_tree")
   419   object Rm_Tree extends Scala.Fun_Strings("rm_tree")
   420   {
   420   {
   421     val here = Scala_Project.here
   421     val here = Scala_Project.here
   422     def apply(arg: String): String = apply_paths1(arg, rm_tree)
   422     def apply(args: List[String]): List[String] = apply_paths1(args, rm_tree)
   423   }
   423   }
   424 
   424 
   425   def tmp_dir(name: String, base_dir: JFile = isabelle_tmp_prefix()): JFile =
   425   def tmp_dir(name: String, base_dir: JFile = isabelle_tmp_prefix()): JFile =
   426   {
   426   {
   427     val dir = Files.createTempDirectory(base_dir.toPath, name).toFile
   427     val dir = Files.createTempDirectory(base_dir.toPath, name).toFile