-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathproject.go
53 lines (42 loc) · 969 Bytes
/
project.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
package droidalyzer
import (
"fmt"
"os"
"path/filepath"
)
// Project represents an Android project
type Project struct {
Name string
Path string
Libraries map[string]struct{}
APFiles []APFile
}
// NewProject creates and returns a new Project object
func NewProject(name string, path string) *Project {
p := &Project{}
p.Name = name
p.Path = path
p.Libraries = make(map[string]struct{})
return p
}
// Scan scans all files of the project and loads them into APFiles
func (p *Project) Scan() error {
err := filepath.Walk(p.Path, func(path string, info os.FileInfo, err error) error {
if err != nil {
return err
}
f := NewAPFile(info.Name(), path, filepath.Ext(path))
p.APFiles = append(p.APFiles, *f)
return nil
})
if err != nil {
return err
}
return nil
}
// PrintLibs prints libraries contained in Project struct
func (p *Project) PrintLibs() {
for libs := range p.Libraries {
fmt.Println("Library:", libs)
}
}