Skip to content

Commit

Permalink
FIX: move wildcard from base to mezz + test
Browse files Browse the repository at this point in the history
  • Loading branch information
Oldes committed Dec 18, 2020
1 parent b71d816 commit 2052b22
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 14 deletions.
14 changes: 0 additions & 14 deletions src/mezz/base-files.reb
Original file line number Diff line number Diff line change
Expand Up @@ -176,20 +176,6 @@ split-path: func [
reduce [dir pos]
]

wildcard: func [
"Return block of absolute path files filtered using wildcards."
path [file!] "Source directory"
value [any-string!] "Search value with possible * and ? wildcards"
/local result
][
result: make block! 8
path: clean-path/dir path
foreach file read path [
if find/match/any file value [ append result path/:file ]
]
new-line/all result true
]

intern: function [
"Imports (internalize) words and their values from the lib into the user context."
data [block! any-word!] "Word or block of words to be added (deeply)"
Expand Down
14 changes: 14 additions & 0 deletions src/mezz/mezz-files.reb
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,20 @@ clean-path: func [
reverse out
]

wildcard: func [
"Return block of absolute path files filtered using wildcards."
path [file!] "Source directory"
value [any-string!] "Search value with possible * and ? wildcards"
/local result
][
result: make block! 8
path: clean-path/dir path
foreach file read path [
if find/match/any file value [ append result path/:file ]
]
new-line/all result true
]

input: func [
{Inputs a string from the console.}
/hide "Turns off echoing inputs"
Expand Down
19 changes: 19 additions & 0 deletions src/tests/units/file-test.r3
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,23 @@ secure [%/ allow]
delete %temp.txt
===end-group===

===start-group=== "WILDCARD"
--test-- "wildcard *"
--assert all [
block? files: wildcard %units/files/ %*.zip
empty? find/last/tail files/1 %.zip
]
--assert empty? wildcard %units/files/ %*.something
--test-- "wildcard ?"
--assert all [
block? files: wildcard %units/files/ %issue-2186-UTF??-BE.txt
2 = length? files
]
--test-- "wildcard *?*"
--assert all [
block? probe files: wildcard %units/files/ %*2186-UTF??*.txt
4 = length? files
]
===end-group===

~~~end-file~~~

0 comments on commit 2052b22

Please sign in to comment.