diff options
author | Paul Phillips <paulp@improving.org> | 2009-08-05 14:17:06 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2009-08-05 14:17:06 +0000 |
commit | d32130e1f4795b0d5c9ac891474c88c3884ee898 (patch) | |
tree | c9fcafe52639988aceecc6c13633941034de64ab /src/compiler | |
parent | 4226a1ffb1bcdf7a7f93a8d239fd450c33c0c987 (diff) | |
download | scala-d32130e1f4795b0d5c9ac891474c88c3884ee898.tar.gz scala-d32130e1f4795b0d5c9ac891474c88c3884ee898.tar.bz2 scala-d32130e1f4795b0d5c9ac891474c88c3884ee898.zip |
Fix for #1498.
Diffstat (limited to 'src/compiler')
-rw-r--r-- | src/compiler/scala/tools/nsc/CompileClient.scala | 48 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/CompileSocket.scala | 42 |
2 files changed, 25 insertions, 65 deletions
diff --git a/src/compiler/scala/tools/nsc/CompileClient.scala b/src/compiler/scala/tools/nsc/CompileClient.scala index 60215719bf..7c639e013b 100644 --- a/src/compiler/scala/tools/nsc/CompileClient.scala +++ b/src/compiler/scala/tools/nsc/CompileClient.scala @@ -29,13 +29,14 @@ class StandardCompileClient { def absFileNames(paths: String) = { val sep = File.pathSeparator val pathsList = paths.split(sep).toList - pathsList.map(absFileName).mkString("", sep, "") + pathsList map absFileName mkString sep } protected def normalize(args: Array[String]): (String, String) = { - var i = 0 + var i = 0 val vmArgs = new StringBuilder var serverAdr = "" + while (i < args.length) { val arg = args(i) if (fileEndings exists(arg endsWith _)) { @@ -52,18 +53,17 @@ class StandardCompileClient { shutdown = true } i += 1 + if (i < args.length) { - if (arg == "-classpath" || - arg == "-sourcepath" || - arg == "-bootclasspath" || - arg == "-extdirs" || - arg == "-d") { - args(i) = absFileNames(args(i)) - i += 1 - } else if (arg == "-server") { - serverAdr = args(i) - args(i-1) = "" - args(i) = "" + arg match { + case "-classpath" | "-sourcepath" | "-bootclasspath" | "-extdirs" | "-d" => + args(i) = absFileNames(args(i)) + i += 1 + case "-server" => + serverAdr = args(i) + args(i-1) = "" + args(i) = "" + case _ => } } } @@ -72,13 +72,9 @@ class StandardCompileClient { // used by class ant.FastScalac to skip exit statement in Ant. def main0(args0: Array[String]): Int = { - val args = - if (args0.exists(arg => arg == "-d")) - args0 - else - ("-d" :: "." :: args0.toList).toArray - + val args = if (args0 contains "-d") args0 else Array("-d", ".") ++ args0 val (vmArgs, serverAdr) = normalize(args) + if (version) { Console.println(versionMsg) return 0 @@ -109,21 +105,13 @@ class StandardCompileClient { Console.println(fromServer) fromServer = in.readLine() } - in.close() - out.close() - socket.close() + in.close ; out.close ; socket.close } if (sawerror) 1 else 0 } - def main(args: Array[String]) { - try { - val status = main0(args) - exit(status) - } catch { - case e: Exception => exit(1) - } - } + def main(args: Array[String]): Unit = + exit(try main0(args) catch { case e: Exception => 1 }) } 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 */ |