Path Matcher
Examples of using path matchers, such as IsFile, to select/match files and directories
Default Matchers
Demonstrate matching using the matchers that are provided in Path.Matching
import scalax.file.Path
import scalax.file.PathMatcher._
// This example tests if the path is a file, directory, exists or does not exist
Path("/tmp/file") match {
case IsFile(file) => println("it's a file!" + file)
case IsDirectory(dir) => println("it's a directory!" + dir)
case Exists(path) => println("It exists... but what is it?" + path)
case NonExistent(path) => println("It does not exist!" + path)
case _ => println("I give up")
}
// Now match based on the permissions of the path
// Set up matchers we want to use
import Path.AccessModes._
val RWE = new AccessMatcher(Read, Write, Execute)
val RW = new AccessMatcher(Read, Write)
val R = new AccessMatcher(Read)
Path("/tmp/file") match {
case RWE(path) => println("path is rwe" + path)
case RW(path) => println("path is rw" + path)
case R(path) => println("path is r" + path)
}