Citycide Glob Versions Save

Pure Nim library for matching file paths against Unix style glob patterns.

v0.11.3

3 months ago
BUG FIXES

v0.11.2

1 year ago
BUG FIXES

v0.11.1

3 years ago
BUG FIXES

v0.11.0

3 years ago
FEATURES
  • enable negative match patterns (83bdafc)

v0.10.0

3 years ago
BREAKING CHANGES
  • Nim v1.x is now required.
BUG FIXES
  • make GlobSyntaxError derive from CatchableError (09e50e1)
  • change toPattern to re to avoid deprecation warnings (cb7cdd9)

v0.9.1

3 years ago
BUG FIXES
CONTRIBUTORS

This release was made possible by:

Thanks!

v0.9.0

5 years ago
BREAKING CHANGES
  • walk: absolute patterns now result in absolute paths if no root is provided (even if Absolute notin options)
FEATURES
  • walk: make Absolute option handling smarter (#27) (589671a), closes #23
BUG FIXES
  • walk: ensure hidden directories are not entered on non-Windows systems (1ea34f9)
  • walk: match filesystem casing for entries on macOS (#33) (d9d1175)
  • compat: support future module relocation in nim devel (#31) (ffd65d3)
  • walk: handle leading shallow magic correctly (#30) (1fa54df), closes #29
  • walk: handle leading magic correctly pt. 2 (633a87d), closes #29
  • windows: improve case insensitive path handling (4a0d545)
CONTRIBUTORS

This release was made possible through contributions by:

Thanks!

v0.8.1

5 years ago
BUG FIXES
  • change expandGlob back to proc (98a5c79), closes #21

v0.8.0

5 years ago

Greetings from v0.8.0 — a significant release that cleans up the API and provides several new features!

listGlob removal

The seq-returning proc listGlob is also removed to encourage the use of the iterators walkGlob or walkGlobKinds. It's also easy enough to get a seq from these using sequtils.toSeq from Nim's stdlib that it was mostly unnecessary.

GlobOption flags

Options (like includeDirs or includeHidden) are no longer provided as individual boolean parameters and are instead part of a set[GlobOption], the default for which is exported as defaultGlobOptions. You can alter this like you would any other set using unions and intersections:

import glob
import sequtils

const options = defaultGlobOptions + {Hidden, FollowLinks} - {Files}
echo toSeq(walkGlob("src", options = options))

# or replace the default options completely
echo toSeq(walkGlob("src", options = {Hidden}))
# @[... only hidden files under src/ ...]

Several of these flags are equivalent to parameters in the <=0.7.0 API, but a few of them are new:

pre-0.8.0 0.8.0 flag meaning
relative = false GlobOption.Absolue yield paths as absolute rather than relative to root
expandDirs = false GlobOption.NoExpandDirs if pattern is a directory don't treat it as <dir>/**/*
includeHidden = true GlobOption.Hidden yield hidden files or directories
includeDirs = true GlobOption.Directories yield directories
N/A GlobOption.IgnoreCase matching will ignore case differences
N/A GlobOption.Files yield files
N/A GlobOption.DirLinks yield links to directories
N/A GlobOption.FileLinks yield links to files
N/A GlobOption.FollowLinks recurse into directories through links

So this new options set allows for more granular things like only returning links:

for path in walkGlob(".", options = {FileLinks, DirLinks}):
  # only links!
  discard

Case-insensitive matching

Patterns can now be made case-insensitive, which works even on platforms with case-sensitive filesystems. The defaultGlobOptions on Windows will include GlobOption.IgnoreCase and patterns created on Windows will be case-insensitive by default.

Advanced filtering

When the options flags aren't enough, you can do a lot more with the optional filterYield or filterDescend procs to decide what gets yielded and what directories are traversed.

type
  FilterDescend* = (path: string) -> bool
  FilterYield* = (path: string, kind: PathComponent) -> bool

filterDescend is called whenever the iterator comes across a directory that is about to be recursed into. If you return false, the iterator will abandon that recursion. Any path received by a filterDescend proc is guaranteed to be a directory or a link to a directory.

filterYield is called whenever an item (file, directory, or link) is about to be yielded. If you return false, the iterator will not yield the item.

BREAKING CHANGES
  • listGlob has been removed to encourage the use of iterators. sequtils.toSeq from Nim's stdlib can be used to convert the iterators to seqs
  • The walk iterators now take an options set rather than multiple boolean parameters
  • GlobResult has been renamed GlobEntry
FEATURES
  • support case insensitive matching (fe17bdd)
  • windows: match casing of expanded directories to filesystem (76e1582)
  • rename GlobResult to GlobEntry (34fa6f3)
  • forward os.PathComponent for ease of use (de74aff)
BUG FIXES
  • walk: expand magic if given a glob (8ef605b)
  • handle empty base paths when joining (0cdb00f)
  • don't recurse into hidden directories when includeHidden == false (#14) (b6de2fd)
PERFORMANCE
  • walk: move some processing inside proceed check (cfabbea)

v0.7.0

5 years ago
FEATURES
  • normalize returned paths to current os style (966e8cf)
  • remove $ to improve inspection & debugging (c897d6b)
BUG FIXES
  • handle absolute paths correctly (1753cb8)