src/Pure/System/isabelle_system.scala
changeset 76144 35a279a2d246
parent 75702 97e8f4c938bf
child 76145 a6bdf4b889ca
equal deleted inserted replaced
76142:e8d4013c49d1 76144:35a279a2d246
   267     val path = Path.explode("$ISABELLE_TMP_PREFIX")
   267     val path = Path.explode("$ISABELLE_TMP_PREFIX")
   268     path.file.mkdirs  // low-level mkdirs to avoid recursion via Isabelle environment
   268     path.file.mkdirs  // low-level mkdirs to avoid recursion via Isabelle environment
   269     File.platform_file(path)
   269     File.platform_file(path)
   270   }
   270   }
   271 
   271 
   272   def tmp_file(name: String, ext: String = "", base_dir: JFile = isabelle_tmp_prefix()): JFile = {
   272   def tmp_file(
       
   273     name: String,
       
   274     ext: String = "",
       
   275     base_dir: JFile = isabelle_tmp_prefix(),
       
   276     initialized: Boolean = true
       
   277   ): JFile = {
   273     val suffix = if (ext == "") "" else "." + ext
   278     val suffix = if (ext == "") "" else "." + ext
   274     val file = Files.createTempFile(base_dir.toPath, name, suffix).toFile
   279     val file = Files.createTempFile(base_dir.toPath, name, suffix).toFile
   275     file.deleteOnExit()
   280     if (initialized) file.deleteOnExit() else file.delete()
   276     file
   281     file
   277   }
   282   }
   278 
   283 
   279   def with_tmp_file[A](name: String, ext: String = "")(body: Path => A): A = {
   284   def with_tmp_file[A](name: String, ext: String = "")(body: Path => A): A = {
   280     val file = tmp_file(name, ext)
   285     val file = tmp_file(name, ext)