diff options
author | Christopher Vogt <oss.nsp@cvogt.org> | 2016-03-07 01:36:40 -0500 |
---|---|---|
committer | Christopher Vogt <oss.nsp@cvogt.org> | 2016-03-07 01:36:40 -0500 |
commit | e958dec0dbbcf7f7a28cd21641e76390fb3dba6a (patch) | |
tree | ec0933e230b0c3f222fceb82b3eec177d56ea979 /stage1/ClassPath.scala | |
parent | f0dc760df8757caea1d83b15142a3d0704488636 (diff) | |
download | cbt-e958dec0dbbcf7f7a28cd21641e76390fb3dba6a.tar.gz cbt-e958dec0dbbcf7f7a28cd21641e76390fb3dba6a.tar.bz2 cbt-e958dec0dbbcf7f7a28cd21641e76390fb3dba6a.zip |
cleanup: whitespace changes, separated more things into their own files, use ++ for strings everywhere. Added ++ method to File and URL and use it in many places
Diffstat (limited to 'stage1/ClassPath.scala')
-rw-r--r-- | stage1/ClassPath.scala | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/stage1/ClassPath.scala b/stage1/ClassPath.scala new file mode 100644 index 0000000..66a1b44 --- /dev/null +++ b/stage1/ClassPath.scala @@ -0,0 +1,30 @@ +package cbt +import java.io._ +import java.net._ +import scala.collection.immutable.Seq + +object ClassPath{ + def apply(files: File*): ClassPath = ClassPath(files.toVector) + def flatten( classPaths: Seq[ClassPath] ): ClassPath = ClassPath( classPaths.map(_.files).flatten ) +} +case class ClassPath(files: Seq[File]){ + private val duplicates = (files diff files.distinct).distinct + assert( + duplicates.isEmpty, + "Duplicate classpath entries found:\n" ++ duplicates.mkString("\n") ++ "\nin classpath:\n"++string + ) + private val nonExisting = files.distinct.filterNot(_.exists) + assert( + duplicates.isEmpty, + "Classpath contains entires that don't exist on disk:\n" ++ nonExisting.mkString("\n") ++ "\nin classpath:\n"++string + ) + + def +:(file: File) = ClassPath(file +: files) + def :+(file: File) = ClassPath(files :+ file) + def ++(other: ClassPath) = ClassPath(files ++ other.files) + def string = strings.mkString( File.pathSeparator ) + def strings = files.map{ + f => f.string ++ ( if(f.isDirectory) "/" else "" ) + } + def toConsole = string +} |