@@ -10,14 +10,6 @@ See `primitive Glob` for additional usage details.
1010use " files"
1111use " regex"
1212
13- interface GlobHandler
14- """
15- A handler for `Glob.iglob`. Each path which matches the glob will be called
16- with the groups that matched the various wildcards supplies in the
17- `match_groups` array.
18- """
19- fun ref apply (path: FilePath , match_groups: Array [String ])
20-
2113primitive Glob
2214 """
2315 Filename matching and globbing with shell patterns.
@@ -49,7 +41,9 @@ primitive Glob
4941 fnmatchcase (Path .normcase (name), Path .normcase (pattern))
5042
5143 fun fnmatchcase (name: String , pattern: String ): Bool =>
52- """ Tests whether `name` matches `pattern`, including case."""
44+ """
45+ Tests whether `name` matches `pattern`, including case.
46+ """
5347 try
5448 Regex (translate (pattern))? == name
5549 else
@@ -122,7 +116,8 @@ primitive Glob
122116 res.append (" \\ ^" )
123117 i = i + 1
124118 end
125- let sub = recover ref pat.substring (i.isize (), j.isize ()) end
119+ let sub =
120+ recover ref pat.substring (i.isize (), j.isize ()) end
126121 res.append (sub .> replace (" \\ " ," \\\\ " ))
127122 res.append (" ])" )
128123 i = j + 1
@@ -148,7 +143,7 @@ primitive Glob
148143 on `Glob` for details.
149144 """
150145 let res = Array [FilePath ]
151- iglob (root_path, pattern, {(path, _) => res.push (path)})
146+ iglob (root_path, pattern, {(path, _) => res.push (path) })
152147 res
153148
154149 fun _apply_glob_to_walk (
@@ -162,12 +157,13 @@ primitive Glob
162157 for e in entries.values () do
163158 try
164159 let p = dir.join (e)?
165- let m = compiled_pattern (
166- if Path .is_abs (pattern) then
167- p.path
168- else
169- Path .rel (root.path , p.path )?
170- end )?
160+ let m =
161+ compiled_pattern (
162+ if Path .is_abs (pattern) then
163+ p.path
164+ else
165+ Path .rel (root.path , p.path )?
166+ end )?
171167 glob_handler (p, m.groups ())
172168 end
173169 end
@@ -184,5 +180,8 @@ primitive Glob
184180 // not contain wildcards and expanding them before walking.
185181 try
186182 root.walk (this ~_apply_glob_to_walk (
187- pattern, Regex (translate (Path .normcase (pattern)))?, root, glob_handler))
183+ pattern,
184+ Regex (translate (Path .normcase (pattern)))?,
185+ root,
186+ glob_handler))
188187 end
0 commit comments