Some minor compiler support bits for my upcoming partest patch.

No review.

git-svn-id: http://lampsvn.epfl.ch/svn-repos/scala/scala/trunk@21125 5e8d7ff9-d8ef-0310-90f0-a4852d11357a
This commit is contained in:
extempore 2010-03-10 16:21:56 +00:00
parent 0be7626fad
commit 6fe9c8d3a0
5 changed files with 12 additions and 8 deletions

View File

@ -12,8 +12,7 @@ package io
import java.io.{ File => JFile }
import collection.Traversable
object Directory
{
object Directory {
import scala.util.Properties.{ tmpDir, userHome, userDir }
private def normalizePath(s: String) = Some(apply(Path(s).normalize))
@ -21,7 +20,7 @@ object Directory
def Home: Option[Directory] = if (userHome == "") None else normalizePath(userHome)
def TmpDir: Option[Directory] = if (tmpDir == "") None else normalizePath(tmpDir)
def apply(path: Path) = path.toDirectory
def apply(path: Path): Directory = path.toDirectory
// Like File.makeTemp but creates a directory instead
def makeTemp(prefix: String = Path.randomPrefix, suffix: String = null, dir: JFile = null): Directory = {

View File

@ -61,6 +61,7 @@ object Path
def roots: List[Path] = JFile.listRoots().toList map Path.apply
def apply(segments: Seq[String]): Path = apply(segments mkString JFile.separator)
def apply(path: String): Path = apply(new JFile(path))
def apply(jfile: JFile): Path =
if (jfile.isFile) new File(jfile)
@ -75,8 +76,7 @@ import Path._
/** The Path constructor is private so we can enforce some
* semantics regarding how a Path might relate to the world.
*/
class Path private[io] (val jfile: JFile)
{
class Path private[io] (val jfile: JFile) {
val separator = JFile.separatorChar
val separatorStr = JFile.separator

View File

@ -31,7 +31,8 @@ abstract class Reporter {
}
var cancelled: Boolean = false
def hasErrors: Boolean = ERROR.count != 0 || cancelled
def hasErrors: Boolean = ERROR.count > 0 || cancelled
def hasWarnings: Boolean = WARNING.count > 0
/** Flush all output */
def flush() { }

View File

@ -79,8 +79,11 @@ object ClassPath {
/** Split the classpath, filter according to predicate, and reassemble. */
def filter(cp: String, p: String => Boolean): String = join(split(cp) filter p: _*)
/** Split the classpath and map them into urls */
def toURLs(cp: String): List[URL] = split(cp) map (x => Path(x).toAbsolute.toURL)
/** Split the classpath and map them into Paths */
def toPaths(cp: String): List[Path] = split(cp) map (x => Path(x).toAbsolute)
/** Split the classpath and map them into URLs */
def toURLs(cp: String): List[URL] = toPaths(cp) map (_.toURL)
/** Expand path and possibly expanding stars */
def expandPath(path: String, expandStar: Boolean = true): List[String] =

View File

@ -77,6 +77,7 @@ case class CommandLine(
def isSet(arg: String) = args contains arg
def get(arg: String) = argMap get arg
def getOrElse(arg: String, orElse: => String) = if (isSet(arg)) apply(arg) else orElse
def apply(arg: String) = argMap(arg)
override def toString() = "CommandLine(\n%s)\n" format (args map (" " + _ + "\n") mkString)