Skip to content

Commit 2052b22

Browse files
committed
FIX: move wildcard from base to mezz + test
1 parent b71d816 commit 2052b22

File tree

3 files changed

+33
-14
lines changed

3 files changed

+33
-14
lines changed

src/mezz/base-files.reb

-14
Original file line numberDiff line numberDiff line change
@@ -176,20 +176,6 @@ split-path: func [
176176
reduce [dir pos]
177177
]
178178

179-
wildcard: func [
180-
"Return block of absolute path files filtered using wildcards."
181-
path [file!] "Source directory"
182-
value [any-string!] "Search value with possible * and ? wildcards"
183-
/local result
184-
][
185-
result: make block! 8
186-
path: clean-path/dir path
187-
foreach file read path [
188-
if find/match/any file value [ append result path/:file ]
189-
]
190-
new-line/all result true
191-
]
192-
193179
intern: function [
194180
"Imports (internalize) words and their values from the lib into the user context."
195181
data [block! any-word!] "Word or block of words to be added (deeply)"

src/mezz/mezz-files.reb

+14
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,20 @@ clean-path: func [
6262
reverse out
6363
]
6464

65+
wildcard: func [
66+
"Return block of absolute path files filtered using wildcards."
67+
path [file!] "Source directory"
68+
value [any-string!] "Search value with possible * and ? wildcards"
69+
/local result
70+
][
71+
result: make block! 8
72+
path: clean-path/dir path
73+
foreach file read path [
74+
if find/match/any file value [ append result path/:file ]
75+
]
76+
new-line/all result true
77+
]
78+
6579
input: func [
6680
{Inputs a string from the console.}
6781
/hide "Turns off echoing inputs"

src/tests/units/file-test.r3

+19
Original file line numberDiff line numberDiff line change
@@ -76,4 +76,23 @@ secure [%/ allow]
7676
delete %temp.txt
7777
===end-group===
7878

79+
===start-group=== "WILDCARD"
80+
--test-- "wildcard *"
81+
--assert all [
82+
block? files: wildcard %units/files/ %*.zip
83+
empty? find/last/tail files/1 %.zip
84+
]
85+
--assert empty? wildcard %units/files/ %*.something
86+
--test-- "wildcard ?"
87+
--assert all [
88+
block? files: wildcard %units/files/ %issue-2186-UTF??-BE.txt
89+
2 = length? files
90+
]
91+
--test-- "wildcard *?*"
92+
--assert all [
93+
block? probe files: wildcard %units/files/ %*2186-UTF??*.txt
94+
4 = length? files
95+
]
96+
===end-group===
97+
7998
~~~end-file~~~

0 commit comments

Comments
 (0)