-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathglob_set.go
More file actions
39 lines (32 loc) · 825 Bytes
/
glob_set.go
File metadata and controls
39 lines (32 loc) · 825 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package mpq
import (
"path/filepath"
)
// Opens a [Set] of archives using a list of glob patterns
func GlobSet(patterns ...string) (set *Set, err error) {
set = NewSet()
// glob archive paths
var matched = map[string]bool{}
var archive_list []string
var matched_by_pattern []string
var archive *Archive
for _, pattern := range patterns {
matched_by_pattern, err = filepath.Glob(pattern)
if err != nil {
return
}
archive_list = append(archive_list, matched_by_pattern...)
}
// attempt to open globbed archive paths
for _, archive_path := range archive_list {
if !matched[archive_path] {
archive, err = Open(archive_path)
if err != nil {
return
}
set.archives = append(set.archives, archive)
matched[archive_path] = true
}
}
return
}