From d9a7d026ce8d48c9bf9d8eb669a3a9430105120e Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Mon, 31 Aug 2009 20:19:46 +0000 Subject: One more try to unbreak fsc all the way. --- src/compiler/scala/tools/nsc/CompileServer.scala | 2 +- src/compiler/scala/tools/nsc/CompileSocket.scala | 1 + src/compiler/scala/tools/nsc/io/PlainFile.scala | 2 +- src/library/scala/io/Path.scala | 4 ++++ src/library/scala/xml/persistent/CachedFileStorage.scala | 2 +- 5 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/compiler/scala/tools/nsc/CompileServer.scala b/src/compiler/scala/tools/nsc/CompileServer.scala index 37f57bb862..4e037201a4 100644 --- a/src/compiler/scala/tools/nsc/CompileServer.scala +++ b/src/compiler/scala/tools/nsc/CompileServer.scala @@ -145,7 +145,7 @@ class StandardCompileServer extends SocketServer private val redirectDir = (compileSocket.tmpDir / "output-redirects").ensureDirectory() private def redirect(setter: PrintStream => Unit, filename: String): Unit = - setter(new PrintStream((redirectDir / filename).createFile.bufferedOutput())) + setter(new PrintStream((redirectDir / filename).ensureFile.bufferedOutput())) def main(args: Array[String]) { redirect(System.setOut, "scala-compile-server-out.log") diff --git a/src/compiler/scala/tools/nsc/CompileSocket.scala b/src/compiler/scala/tools/nsc/CompileSocket.scala index 9b31cfe846..d65485d998 100644 --- a/src/compiler/scala/tools/nsc/CompileSocket.scala +++ b/src/compiler/scala/tools/nsc/CompileSocket.scala @@ -121,6 +121,7 @@ class CompileSocket { if (port < 0) startNewServer(vmArgs) + while (port < 0 && attempts < MaxAttempts) { attempts += 1 Thread.sleep(sleepTime) diff --git a/src/compiler/scala/tools/nsc/io/PlainFile.scala b/src/compiler/scala/tools/nsc/io/PlainFile.scala index 7e5e8576b1..359f062f41 100644 --- a/src/compiler/scala/tools/nsc/io/PlainFile.scala +++ b/src/compiler/scala/tools/nsc/io/PlainFile.scala @@ -77,7 +77,7 @@ class PlainFile(val givenPath: Path) extends AbstractFile { } /** Does this abstract file denote an existing file? */ - def create: Unit = if (!exists) givenPath.createFile() + def create: Unit = if (!exists) givenPath.ensureFile() /** Delete the underlying file or directory (recursively). */ def delete: Unit = diff --git a/src/library/scala/io/Path.scala b/src/library/scala/io/Path.scala index 043cb3e66b..3d2bfaeca5 100644 --- a/src/library/scala/io/Path.scala +++ b/src/library/scala/io/Path.scala @@ -151,6 +151,10 @@ class Path private[io] (val jfile: JFile) def ensureDirectory(force: Boolean = true): Directory = if (this.isDirectory) this.toDirectory else createDirectory(force) + /** This is temporary while I try to unbreak fsc. */ + def ensureFile(): File = + if (this.isFile) this.toFile else createFile() + // deletions def delete() = jfile.delete() def deleteIfExists() = if (jfile.exists()) delete() else false diff --git a/src/library/scala/xml/persistent/CachedFileStorage.scala b/src/library/scala/xml/persistent/CachedFileStorage.scala index 17194b4421..8b3907b7f5 100644 --- a/src/library/scala/xml/persistent/CachedFileStorage.scala +++ b/src/library/scala/xml/persistent/CachedFileStorage.scala @@ -81,7 +81,7 @@ extends java.lang.Thread with scala.util.logging.Logged log("[save]\ndeleting "+theFile); theFile.delete(); log("creating new "+theFile); - theFile.createFile(); + theFile.ensureFile(); val fos = theFile.outputStream() val c = fos.getChannel() -- cgit v1.2.3