Generate an error when making a path string from paths containing the separator. Fixes #1038.

This is an attempt to provide a decent error message in some cases.  However, paths that include
the Java path separator character are just fundamentally problematic and aren't always going to
be cleanly detected.
This commit is contained in:
Mark Harrah 2013-12-18 11:35:12 -05:00
parent 5df24e5eb2
commit ca4b22e272
1 changed files with 5 additions and 1 deletions

View File

@ -68,7 +68,11 @@ object Path extends PathExtra
def absolute(file: File): File = new File(file.toURI.normalize).getAbsoluteFile
def makeString(paths: Seq[File]): String = makeString(paths, pathSeparator)
def makeString(paths: Seq[File], sep: String): String = paths.map(_.getAbsolutePath).mkString(sep)
def makeString(paths: Seq[File], sep: String): String = {
val separated = paths.map(_.getAbsolutePath)
separated.find(_ contains sep).foreach( p => sys.error(s"Path '$p' contains separator '$sep'") )
separated.mkString(sep)
}
def newerThan(a: File, b: File): Boolean = a.exists && (!b.exists || a.lastModified > b.lastModified)
/** The separator character of the platform.*/