diff options
author | Paul Phillips <paulp@improving.org> | 2010-03-11 06:00:37 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2010-03-11 06:00:37 +0000 |
commit | d12ea6d31fa2624cb88f031d346ec13d74992302 (patch) | |
tree | e58b11b44639ce89d56397e7cdd0ce3f18213000 /src | |
parent | 6aa285809c9866cac866ffcad93d073b3ed0397d (diff) | |
download | scala-d12ea6d31fa2624cb88f031d346ec13d74992302.tar.gz scala-d12ea6d31fa2624cb88f031d346ec13d74992302.tar.bz2 scala-d12ea6d31fa2624cb88f031d346ec13d74992302.zip |
Some IO conveniences. No review.
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/scala/tools/nsc/io/Directory.scala | 3 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/io/Path.scala | 5 |
2 files changed, 8 insertions, 0 deletions
diff --git a/src/compiler/scala/tools/nsc/io/Directory.scala b/src/compiler/scala/tools/nsc/io/Directory.scala index 3749cf6e67..965ac51203 100644 --- a/src/compiler/scala/tools/nsc/io/Directory.scala +++ b/src/compiler/scala/tools/nsc/io/Directory.scala @@ -54,6 +54,9 @@ class Directory(jfile: JFile) extends Path(jfile) def dirs: Iterator[Directory] = list partialMap { case x: Directory => x } def files: Iterator[File] = list partialMap { case x: File => x } + def deepDirs: Iterator[Directory] = Path.onlyDirs(deepList()) + def deepFiles: Iterator[File] = Path.onlyFiles(deepList()) + /** If optional depth argument is not given, will recurse * until it runs out of contents. */ diff --git a/src/compiler/scala/tools/nsc/io/Path.scala b/src/compiler/scala/tools/nsc/io/Path.scala index ed09aac3bb..823e11b304 100644 --- a/src/compiler/scala/tools/nsc/io/Path.scala +++ b/src/compiler/scala/tools/nsc/io/Path.scala @@ -59,6 +59,11 @@ object Path // true // } + def onlyDirs(xs: Iterator[Path]): Iterator[Directory] = xs filter (_.isDirectory) map (_.toDirectory) + def onlyDirs(xs: List[Path]): List[Directory] = xs filter (_.isDirectory) map (_.toDirectory) + def onlyFiles(xs: Iterator[Path]): Iterator[File] = xs filter (_.isFile) map (_.toFile) + def onlyFiles(xs: List[Path]): List[File] = xs filter (_.isFile) map (_.toFile) + def roots: List[Path] = JFile.listRoots().toList map Path.apply def apply(segments: Seq[String]): Path = apply(segments mkString JFile.separator) |