Skip to content

Commit

Permalink
Add util to list with filter
Browse files Browse the repository at this point in the history
  • Loading branch information
pathikrit committed Jul 17, 2018
1 parent bfccb50 commit 41e521b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ better-files follows the following `MAJOR.MINOR.PATCH` release conventions:
* [Issue #123](https://github.com/pathikrit/better-files/issues/233): Rename ManagedResource to Dispose
* [Issue #241](https://github.com/pathikrit/better-files/issues/241): Remove resource leak from directory empty check
* [Issue #242](https://github.com/pathikrit/better-files/issues/242): Support for JDK 9 and JDK 10
* [Remove Files alias](https://github.com/pathikrit/better-files/commit/bfccb5041239bc5413afade4218ec1fb90d3e3d5)

## [v3.5.0](https://github.com/pathikrit/better-files/releases/tag/v3.5.0)
* [PR #230](https://github.com/pathikrit/better-files/pull/230): New Resource APIs with [module safety](https://github.com/pathikrit/better-files/pull/227)
Expand Down
15 changes: 15 additions & 0 deletions core/src/main/scala/better/files/File.scala
Original file line number Diff line number Diff line change
Expand Up @@ -650,6 +650,21 @@ class File private (val path: Path)(implicit val fileSystem: FileSystem = path.g
def isHidden: Boolean =
Files.isHidden(path)

/**
* List files recursively upto given depth using a custom file filter
*
* @param maxDepth
* @param filter
* @param visitOptions
* @return
*/
def list(
maxDepth: Int = Int.MaxValue,
filter: File => Boolean,
visitOptions: File.VisitOptions = File.VisitOptions.default
): Iterator[File] =
Files.find(path, maxDepth, (p, _) => filter(p), visitOptions: _*)

/**
* Check if a file is locked.
*
Expand Down

0 comments on commit 41e521b

Please sign in to comment.