From d32130e1f4795b0d5c9ac891474c88c3884ee898 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Wed, 5 Aug 2009 14:17:06 +0000 Subject: Fix for #1498. --- src/compiler/scala/tools/nsc/CompileSocket.scala | 42 ++++-------------------- 1 file changed, 7 insertions(+), 35 deletions(-) (limited to 'src/compiler/scala/tools/nsc/CompileSocket.scala') diff --git a/src/compiler/scala/tools/nsc/CompileSocket.scala b/src/compiler/scala/tools/nsc/CompileSocket.scala index c22181eabf..1a0fc7d877 100644 --- a/src/compiler/scala/tools/nsc/CompileSocket.scala +++ b/src/compiler/scala/tools/nsc/CompileSocket.scala @@ -58,43 +58,15 @@ class CompileSocket { /** A temporary directory to use */ val tmpDir = { - val totry = List( - ("scala.home", List("var", "scala-devel")), - ("java.io.tmpdir", List("scala-devel")), - ("user.home", List("tmp"))) - - /** Expand a property-extensions pair into a complete File object */ - def expand(trial: (String, List[String])): Option[File] = { - val (topdirProp, extensions) = trial - val topdir = System.getProperty(topdirProp) - if (topdir eq null) - return None - - val fulldir = - extensions.foldLeft[File](new File(topdir))( - (dir,ext) => new File(dir, ext)) - - Some(fulldir) - } + val udir = Option(Properties.userName) getOrElse "shared" + val f = (scala.io.File(Properties.tmpDir) / "scala-devel" / udir).file + f.mkdirs() - /** Try to create directory f, and then see if it can - * be written into. */ - def isDirWritable(f: File): Boolean = { - f.mkdirs() - f.isDirectory && f.canWrite + if (f.isDirectory && f.canWrite) { + info("[Temp directory: " + f + "]") + f } - - def findTmpDir(): File = { - for (trial <- totry) expand(trial) match { - case Some(dir) if isDirWritable(dir) => - info("[Temp directory: " + dir + "]") - return dir - case _ => - } - fatal("Could not find a directory for temporary files") - } - - findTmpDir() + else fatal("Could not find a directory for temporary files") } /* A directory holding port identification files */ -- cgit v1.2.3