Skip to content

Commit

Permalink
Generate an error when making a path string from paths containing the…
Browse files Browse the repository at this point in the history
… 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.
  • Loading branch information
harrah authored and eed3si9n committed Mar 21, 2014
1 parent e80a2b2 commit 12d842f
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion util/io/src/main/scala/sbt/Path.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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.*/
Expand Down

0 comments on commit 12d842f

Please sign in to comment.