2010-06-27 15:18:35 +02:00
|
|
|
/* sbt -- Simple Build Tool
|
|
|
|
|
* Copyright 2010 Mark Harrah
|
|
|
|
|
*/
|
|
|
|
|
package sbt
|
2010-07-02 12:57:03 +02:00
|
|
|
package inc
|
2010-06-27 15:18:35 +02:00
|
|
|
|
2010-11-24 20:08:20 +01:00
|
|
|
import java.io.{File, IOException}
|
2010-06-27 15:18:35 +02:00
|
|
|
import sbinary._
|
|
|
|
|
import Operations.{read, write}
|
|
|
|
|
import DefaultProtocol._
|
|
|
|
|
|
|
|
|
|
object FileBasedStore
|
|
|
|
|
{
|
|
|
|
|
def apply(file: File)(implicit analysisF: Format[Analysis], setupF: Format[CompileSetup]): AnalysisStore = new AnalysisStore {
|
|
|
|
|
def set(analysis: Analysis, setup: CompileSetup): Unit =
|
2010-11-24 20:08:20 +01:00
|
|
|
IO.gzipFileOut(file) { out =>
|
2010-10-30 21:46:44 +02:00
|
|
|
write[(Analysis, CompileSetup)](out, (analysis, setup) )
|
2010-11-24 20:08:20 +01:00
|
|
|
}
|
2010-06-27 15:18:35 +02:00
|
|
|
|
2010-07-02 12:57:03 +02:00
|
|
|
def get(): Option[(Analysis, CompileSetup)] =
|
2011-04-19 23:54:03 +02:00
|
|
|
try { Some(getUncaught()) } catch { case _: Exception => None }
|
2010-07-02 12:57:03 +02:00
|
|
|
def getUncaught(): (Analysis, CompileSetup) =
|
2010-11-24 20:08:20 +01:00
|
|
|
IO.gzipFileIn(file)( in => read[(Analysis, CompileSetup)](in) )
|
2010-06-27 15:18:35 +02:00
|
|
|
}
|
2010-10-30 21:46:44 +02:00
|
|
|
}
|