Glob

Filename matching and globbing with shell patterns.

fnmatch(file_name, pattern) matches according to the local convention. fnmatchcase(file_name, pattern) always takes case into account. The functions operate by translating the pattern into a regular expression.

The function translate(PATTERN) returns a regular expression corresponding to PATTERN.

Patterns are Unix shell style: * | matches multiple characters within a directory ** | matches multiple characters across directories ? | matches any single character [seq] | matches any character in seq [!seq] | matches any char not in seq

primitive val Glob

Constructors

create

new val create()
: Glob val^

Returns


Public Functions

fnmatch

Tests whether name matches pattern.

An initial period in name is not special.

Both name and pattern are first case-normalized if the operating system requires it. If you don't want this, use fnmatchcase.

fun box fnmatch(
  name: String val,
  pattern: String val)
: Bool val

Parameters

Returns


fnmatchcase

Tests whether name matches pattern, including case.

fun box fnmatchcase(
  name: String val,
  pattern: String val)
: Bool val

Parameters

Returns


filter

Returns name and the matching subgroups for names that match pattern.

All strings are first case-normalized if the operating system requires it.

fun box filter(
  names: Array[String val] ref,
  pattern: String val)
: Array[(String val , Array[String val] ref)] val

Parameters

Returns


translate

Translates a shell pattern to a regular expression. There is no way to quote meta-characters.

fun box translate(
  pat: String val)
: String ref^

Parameters

Returns


glob

Returns an Array[FilePath] for each path below root_path that matches pattern.

The pattern may contain shell-style wildcards. See the type documentation on Glob for details.

fun box glob(
  root_path: FilePath val,
  pattern: String val)
: Array[FilePath val] ref

Parameters

Returns


iglob

Calls GlobHandler.apply for each path below root that matches pattern.

The pattern may contain shell-style wildcards. See the type documentation on Glob for details.

fun box iglob(
  root: FilePath val,
  pattern: String val,
  glob_handler: GlobHandler ref)
: None val

Parameters

Returns


eq

fun box eq(
  that: Glob val)
: Bool val

Parameters

Returns


ne

fun box ne(
  that: Glob val)
: Bool val

Parameters

Returns


Private Functions

_apply_glob_to_walk

fun box _apply_glob_to_walk(
  pattern: String val,
  compiled_pattern: Regex ref,
  root: FilePath val,
  glob_handler: GlobHandler ref,
  dir: FilePath val,
  entries: Array[String val] ref)
: None val

Parameters

Returns