sealed trait Glob extends AnyRef
Represents a query for a path on the file system. Instances of Glob
can be combined together
to build a more complicated query. Similar to the path name components of a Path
, a Glob
has
components and matching is done from left to right component-wise. Each component is matched
using a
PathMatcher.
For example,
val baseGlob = Glob("/foo/bar") baseGlob.matches(Paths.get("/foo/bar")) // true baseGlob.matches(Paths.get("/foo")) // false baseGlob.matches(Paths.get("/foo/bar/baz")) // false val children = baseGlob / AnyPath children.matches(Paths.get("/foo/bar")) // false children.matches(Paths.get("/foo/bar/baz")) // true children.matches(Paths.get("/foo/bar/baz/buzz")) false val secondGenerationChildren = children / AnyPath secondGeneration.matches(Paths.get("/foo/bar/baz")) // false secondGeneration.matches(Paths.get("/foo/bar/baz/buzz")) // true secondGeneration.matches(Paths.get("/foo/bar/baz/buzz/fizz")) // false
where AnyPath matches any path name.
Globs can be recursive and are constructed using the RecursiveGlob:
val baseGlob = Glob("/foo/bar") val allDescendants = baseGlob / RecursiveGlob allDescendants.matches(Paths.get("/foo/bar")) // false allDescendants.matches(Paths.get("/foo/bar/baz/buzz.txt")) // true
They can also filter on the basis file names:
val baseGlob = Glob("/foo/bar") val allScalaSources = baseGlob / RecursiveGlob / "*.scala" allScalaSources.matches(Paths.get("/foo/bar/Foo.scala")) // true allScalaSources.matches(Paths.get("/foo/bar/baz/fizz/buzz/Bar.scala")) // true allScalaSources.matches(Paths.get("/foo/bar/baz/fizz/buzz/Buzz.java")) // false val allScalaAndJavaSources = baseGlob / RecursiveGlob / "*.{java,scala}" allScalaAndJavaSources.matches(Paths.get("/foo/bar/baz/fizz/buzz/Bar.scala")) // true allScalaAndJavaSources.matches(Paths.get("/foo/bar/baz/fizz/buzz/Buzz.java")) // true
Linear Supertypes
Known Subclasses
Ordering
- Alphabetic
- By Inheritance
Inherited
- Glob
- AnyRef
- Any
- Hide All
- Show All
Visibility
- Public
- All
Abstract Value Members
Concrete Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native()
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
toString(): String
- Definition Classes
- AnyRef → Any
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native()