summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/CompileSocket.scala
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2009-08-05 14:17:06 +0000
committerPaul Phillips <paulp@improving.org>2009-08-05 14:17:06 +0000
commitd32130e1f4795b0d5c9ac891474c88c3884ee898 (patch)
treec9fcafe52639988aceecc6c13633941034de64ab /src/compiler/scala/tools/nsc/CompileSocket.scala
parent4226a1ffb1bcdf7a7f93a8d239fd450c33c0c987 (diff)
downloadscala-d32130e1f4795b0d5c9ac891474c88c3884ee898.tar.gz
scala-d32130e1f4795b0d5c9ac891474c88c3884ee898.tar.bz2
scala-d32130e1f4795b0d5c9ac891474c88c3884ee898.zip
Fix for #1498.
Diffstat (limited to 'src/compiler/scala/tools/nsc/CompileSocket.scala')
-rw-r--r--src/compiler/scala/tools/nsc/CompileSocket.scala42
1 files changed, 7 insertions, 35 deletions
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 */