src/Pure/System/isabelle_system.scala
changeset 73335 c707655239e2
parent 73333 b70d82358c6d
child 73340 0ffcad1f6130
equal deleted inserted replaced
73334:4f9e4d7d38b4 73335:c707655239e2
    11 import java.io.{File => JFile, IOException}
    11 import java.io.{File => JFile, IOException}
    12 import java.nio.file.{Path => JPath, Files, SimpleFileVisitor, FileVisitResult,
    12 import java.nio.file.{Path => JPath, Files, SimpleFileVisitor, FileVisitResult,
    13   StandardCopyOption, FileSystemException}
    13   StandardCopyOption, FileSystemException}
    14 import java.nio.file.attribute.BasicFileAttributes
    14 import java.nio.file.attribute.BasicFileAttributes
    15 
    15 
    16 
       
    17 import scala.annotation.tailrec
       
    18 
    16 
    19 
    17 
    20 object Isabelle_System
    18 object Isabelle_System
    21 {
    19 {
    22   /** bootstrap information **/
    20   /** bootstrap information **/
   547   }
   545   }
   548 
   546 
   549 
   547 
   550   /* download file */
   548   /* download file */
   551 
   549 
   552   private lazy val curl_check: Unit =
   550   def download(url_name: String, file: Path, progress: Progress = new Progress): Unit =
   553     try { require_command("curl") }
   551   {
   554     catch { case ERROR(msg) => error(msg + " --- cannot download files") }
   552     val url = Url(url_name)
   555 
   553     progress.echo("Getting " + quote(url_name))
   556   def download(url: String, file: Path, progress: Progress = new Progress): Unit =
   554     val bytes =
   557   {
   555       try { Url.read_bytes(url) }
   558     curl_check
   556       catch { case ERROR(msg) => cat_error("Failed to download " + quote(url_name), msg) }
   559     progress.echo("Getting " + quote(url))
   557     Bytes.write(file, bytes)
   560     try {
       
   561       bash("curl --fail --silent --location " + Bash.string(url) +
       
   562         " > " + File.bash_path(file)).check
       
   563     }
       
   564     catch { case ERROR(msg) => cat_error("Failed to download " + quote(url), msg) }
       
   565   }
   558   }
   566 
   559 
   567   object Download extends Scala.Fun("download")
   560   object Download extends Scala.Fun("download")
   568   {
   561   {
   569     val here = Scala_Project.here
   562     val here = Scala_Project.here