diff options
author | Paul Phillips <paulp@improving.org> | 2010-03-13 19:24:43 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2010-03-13 19:24:43 +0000 |
commit | 1b14f49ff297a29c489dd184ee8f1f3c885a1b33 (patch) | |
tree | 7613b903e6cf14d080debdb3c52bef5033e5fba2 /src/compiler/scala/tools/nsc/io | |
parent | 4eade93cfeb1341a136177321746791af3ed95f0 (diff) | |
download | scala-1b14f49ff297a29c489dd184ee8f1f3c885a1b33.tar.gz scala-1b14f49ff297a29c489dd184ee8f1f3c885a1b33.tar.bz2 scala-1b14f49ff297a29c489dd184ee8f1f3c885a1b33.zip |
More support code for the big partest patch I'm...
More support code for the big partest patch I'm working on to finally
finish classpaths for good. No review.
Diffstat (limited to 'src/compiler/scala/tools/nsc/io')
-rw-r--r-- | src/compiler/scala/tools/nsc/io/Directory.scala | 5 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/io/File.scala | 2 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/io/Path.scala | 6 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/io/Process.scala | 18 |
4 files changed, 17 insertions, 14 deletions
diff --git a/src/compiler/scala/tools/nsc/io/Directory.scala b/src/compiler/scala/tools/nsc/io/Directory.scala index 965ac51203..822dfbdffe 100644 --- a/src/compiler/scala/tools/nsc/io/Directory.scala +++ b/src/compiler/scala/tools/nsc/io/Directory.scala @@ -36,8 +36,7 @@ import Path._ * @author Paul Phillips * @since 2.8 */ -class Directory(jfile: JFile) extends Path(jfile) -{ +class Directory(jfile: JFile) extends Path(jfile) { override def toDirectory: Directory = this override def toFile: File = new File(jfile) override def isValid = jfile.isDirectory() || !jfile.exists() @@ -82,6 +81,4 @@ class Directory(jfile: JFile) extends Path(jfile) } f.delete() } - - override def toString() = "Directory(%s)".format(path) } diff --git a/src/compiler/scala/tools/nsc/io/File.scala b/src/compiler/scala/tools/nsc/io/File.scala index d19b2cc269..aecbfbd048 100644 --- a/src/compiler/scala/tools/nsc/io/File.scala +++ b/src/compiler/scala/tools/nsc/io/File.scala @@ -117,6 +117,4 @@ with Streamable.Chars () } - - override def toString() = "File(%s)".format(path) } diff --git a/src/compiler/scala/tools/nsc/io/Path.scala b/src/compiler/scala/tools/nsc/io/Path.scala index 823e11b304..98d981f65e 100644 --- a/src/compiler/scala/tools/nsc/io/Path.scala +++ b/src/compiler/scala/tools/nsc/io/Path.scala @@ -97,6 +97,10 @@ class Path private[io] (val jfile: JFile) { def toAbsolute: Path = if (isAbsolute) this else Path(jfile.getAbsolutePath()) def toURI: URI = jfile.toURI() def toURL: URL = toURI.toURL() + /** If this path is absolute, returns it: otherwise, returns an absolute + * path made up of root / this. + */ + def toAbsoluteWithRoot(root: Path) = if (isAbsolute) this else root.toAbsolute / this /** Creates a new Path with the specified path appended. Assumes * the type of the new component implies the type of the result. @@ -225,7 +229,7 @@ class Path private[io] (val jfile: JFile) { // def copyTo(target: Path, options ...): Boolean // def moveTo(target: Path, options ...): Boolean - override def toString() = "Path(%s)".format(path) + override def toString() = path override def equals(other: Any) = other match { case x: Path => path == x.path case _ => false diff --git a/src/compiler/scala/tools/nsc/io/Process.scala b/src/compiler/scala/tools/nsc/io/Process.scala index 306c88a854..7580cf22ab 100644 --- a/src/compiler/scala/tools/nsc/io/Process.scala +++ b/src/compiler/scala/tools/nsc/io/Process.scala @@ -6,7 +6,7 @@ package scala.tools.nsc package io import concurrent.ThreadRunner -import scala.util.Properties.{ isWin, isMac } +import scala.util.Properties.{ isWin, isMac, lineSeparator } import scala.util.control.Exception.catching import java.lang.{ Process => JProcess, ProcessBuilder => JProcessBuilder } import java.io.{ IOException, InputStream, OutputStream, BufferedReader, InputStreamReader, PrintWriter, File => JFile } @@ -68,8 +68,7 @@ object Process } } - private[Process] class ProcessBuilder(val pb: JProcessBuilder) - { + private[Process] class ProcessBuilder(val pb: JProcessBuilder) { def this(cmd: String*) = this(new JProcessBuilder(cmd: _*)) def start() = new Process(() => pb.start()) @@ -116,7 +115,7 @@ object Process cwd: Path = null, redirect: Boolean = false ): Process = - exec(shell(command), env, cwd) + exec(shell(command), env, cwd, redirect) /** Executes the given command line. * @@ -129,12 +128,11 @@ object Process cwd: Path = null, redirect: Boolean = false ): Process = - new ProcessBuilder(command: _*) withEnv env withCwd cwd start + new ProcessBuilder(command: _*) withEnv env withCwd cwd withRedirectedErrorStream redirect start } import Process._ -class Process(processCreator: () => JProcess) extends Iterable[String] -{ +class Process(processCreator: () => JProcess) extends Iterable[String] { lazy val process = processCreator() def exitValue(): Option[Int] = @@ -144,6 +142,7 @@ class Process(processCreator: () => JProcess) extends Iterable[String] def destroy() = process.destroy() def rerun() = new Process(processCreator) + def slurp() = _out.slurp() def stdout = iterator def iterator = _out.iterator def stderr = _err.iterator @@ -153,6 +152,11 @@ class Process(processCreator: () => JProcess) extends Iterable[String] private val queue = new LinkedBlockingQueue[String] private val reader = new BufferedReader(new InputStreamReader(in)) + def slurp(): String = { + join() + queue.toArray map (_ + lineSeparator) mkString + } + def iterator = { join() // make sure this thread is complete new Iterator[String] { |