From 58f72968ade9d107ad348f737b5d02d7a920c910 Mon Sep 17 00:00:00 2001 From: singularitti Date: Mon, 6 Feb 2023 01:10:06 -0500 Subject: [PATCH] Fix `listfiles` & add `materialize` --- src/Files.jl | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/Files.jl b/src/Files.jl index c8dbf94..d850555 100644 --- a/src/Files.jl +++ b/src/Files.jl @@ -3,7 +3,7 @@ export listfiles using Configurations: @option -using FileTrees: FileTree, Path, files +using FileTrees: FileTree, mapsubtrees, path using Glob: GlobMatch @option struct ExpressFileTree @@ -12,12 +12,19 @@ using Glob: GlobMatch output_pattern::Union{String,Regex,GlobMatch} end -function listfiles(patterns, root_dir=pwd()) - tree = FileTree(root_dir) - return map((patterns.first, patterns.second)) do pattern - subtree = tree[pattern] - abspath.(Path.(files(subtree))) +function listfiles(patterns::Pair, root_dir=pwd()) + tree = FileTree(expanduser(root_dir)) + io = map(patterns) do pattern + files = String[] + mapsubtrees(tree, pattern) do subtree + push!(files, abspath(path(subtree))) + end + files end + return Tuple(io) end +materialize(config::ExpressFileTree) = + listfiles(config.input_pattern => config.output_pattern, config.root_dir) + # end \ No newline at end of file