Open MichaelHatherly opened 4 years ago
That's would be a really nice API addition! I agree it's super clunky to do that right now.
an easy way to do this would be:
!isempty(t[glob"my/file.ext"])
With a glob
it still throws an error if _glob_filter
returns nothing
:
Should that method be returning an empty tree instead?
A couple of one-liner in
methods could be added to bypass that nothing
check I guess?
Base.in(g::GlobMatch, t::FileTree) = _glob_filter(t, name(t), g.pattern...) !== nothing
Base.in(p::PathLike, t::FileTree) = GlobMatch(string(p)) in t
(I might have completely overlooked it if it's already implemented?)
I'd like to check whether a given path exists in a
FileTree
, such asDoes anything like this currently exist? Or is there an idiomatic alternative that's reasonably efficient? There's the
getindex
methods that take globs or regex, but I'm just needing aBool
result given a path.