src/Pure/Thy/sessions.scala
changeset 68219 c0341c0080e2
parent 68218 92050155593e
child 68220 8fc4e3d1df86
equal deleted inserted replaced
68218:92050155593e 68219:c0341c0080e2
   964   def store(options: Options, system_mode: Boolean = false): Store =
   964   def store(options: Options, system_mode: Boolean = false): Store =
   965     new Store(options, system_mode)
   965     new Store(options, system_mode)
   966 
   966 
   967   class Store private[Sessions](val options: Options, val system_mode: Boolean)
   967   class Store private[Sessions](val options: Options, val system_mode: Boolean)
   968   {
   968   {
       
   969     override def toString: String = "Store(output_dir = " + output_dir.expand + ")"
       
   970 
       
   971 
   969     /* file names */
   972     /* file names */
   970 
   973 
   971     def database(name: String): Path = Path.basic("log") + Path.basic(name).ext("db")
   974     def database(name: String): Path = Path.basic("log") + Path.basic(name).ext("db")
   972     def log(name: String): Path = Path.basic("log") + Path.basic(name)
   975     def log(name: String): Path = Path.basic("log") + Path.basic(name)
   973     def log_gz(name: String): Path = log(name).ext("gz")
   976     def log_gz(name: String): Path = log(name).ext("gz")
   974 
   977 
   975 
   978 
   976     /* output */
   979     /* directories */
       
   980 
       
   981     def system_output_dir: Path = Path.explode("~~/heaps/$ML_IDENTIFIER")
       
   982     def user_output_dir: Path = Path.explode("$ISABELLE_HOME_USER/heaps/$ML_IDENTIFIER")
       
   983 
       
   984     def output_dir: Path =
       
   985       if (system_mode) system_output_dir else user_output_dir
       
   986 
       
   987     def input_dirs: List[Path] =
       
   988       if (system_mode) List(system_output_dir)
       
   989       else List(user_output_dir, system_output_dir)
   977 
   990 
   978     val browser_info: Path =
   991     val browser_info: Path =
   979       if (system_mode) Path.explode("~~/browser_info")
   992       if (system_mode) Path.explode("~~/browser_info")
   980       else Path.explode("$ISABELLE_BROWSER_INFO")
   993       else Path.explode("$ISABELLE_BROWSER_INFO")
   981 
   994 
   982     val output_dir: Path =
   995 
   983       if (system_mode) Path.explode("~~/heaps/$ML_IDENTIFIER")
   996     /* output */
   984       else Path.explode("$ISABELLE_OUTPUT")
   997 
   985 
   998     def prepare_output_dir() { Isabelle_System.mkdirs(output_dir + Path.basic("log")) }
   986     override def toString: String = "Store(output_dir = " + output_dir.expand + ")"
       
   987 
       
   988     def prepare_output() { Isabelle_System.mkdirs(output_dir + Path.basic("log")) }
       
   989 
   999 
   990     def output_heap(name: String): Path = output_dir + Path.basic(name)
  1000     def output_heap(name: String): Path = output_dir + Path.basic(name)
   991     def output_log(name: String): Path = output_dir + log(name)
  1001     def output_log(name: String): Path = output_dir + log(name)
   992     def output_log_gz(name: String): Path = output_dir + log_gz(name)
  1002     def output_log_gz(name: String): Path = output_dir + log_gz(name)
   993 
  1003 
   994     def open_output_database(name: String): SQL.Database =
  1004     def open_output_database(name: String): SQL.Database =
   995       SQLite.open_database(output_dir + database(name))
  1005       SQLite.open_database(output_dir + database(name))
   996 
  1006 
   997 
  1007 
   998     /* input */
  1008     /* input */
   999 
       
  1000     private val input_dirs =
       
  1001       if (system_mode) List(output_dir)
       
  1002       else {
       
  1003         val ml_ident = Path.explode("$ML_IDENTIFIER").expand
       
  1004         output_dir :: Path.split(Isabelle_System.getenv_strict("ISABELLE_PATH")).map(_ + ml_ident)
       
  1005       }
       
  1006 
  1009 
  1007     def find_heap(name: String): Option[Path] =
  1010     def find_heap(name: String): Option[Path] =
  1008       input_dirs.map(_ + Path.basic(name)).find(_.is_file)
  1011       input_dirs.map(_ + Path.basic(name)).find(_.is_file)
  1009 
  1012 
  1010     def find_heap_digest(name: String): Option[String] =
  1013     def find_heap_digest(name: String): Option[String] =