-
Notifications
You must be signed in to change notification settings - Fork 9
/
collector.go
58 lines (52 loc) · 1 KB
/
collector.go
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// 24 september 2014
package main
import (
"os"
"strings"
"path/filepath"
)
var cfiles []string
var cppfiles []string
var hfiles []string
var mfiles []string
var mmfiles []string
var rcfiles []string
var base string
func consider(list *[]string, path string) {
if excludeFile(path) {
return
}
*list = append(*list, path)
}
func walker(path string, info os.FileInfo, err error) error {
if err != nil {
return err
}
if base := filepath.Base(path); base != "." && base != ".." && base[0] == '.' {
if info.IsDir() {
return filepath.SkipDir
}
return nil
}
if info.IsDir() {
if excludeDir(path) {
return filepath.SkipDir
}
return nil
}
switch strings.ToLower(filepath.Ext(path)) {
case ".c":
consider(&cfiles, path)
case ".cpp", ".cxx", ".c++", ".cc":
consider(&cppfiles, path)
case ".h", ".hpp", ".hxx", ".h++", ".hh":
consider(&hfiles, path)
case ".m":
consider(&mfiles, path)
case ".mm":
consider(&mmfiles, path)
case ".rc":
consider(&rcfiles, path)
}
return nil
}