-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathfiles.go
55 lines (50 loc) · 1.1 KB
/
files.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
package p4
import "log"
// File has the data for a single file.
type File struct {
Code string
DepotFile string
Revision int64
Action string
Type string
ModTime int64
}
func (f *File) String() string {
return f.DepotFile
}
func (conn *Conn) Files(paths []string) (files []*File, err error) {
var (
results []Result
)
if results, err = conn.RunMarshaled("files", paths); err != nil {
return
}
for idx := range results {
if file, ok := results[idx].(*File); !ok {
log.Printf("type translate err: %s", results[idx])
continue
} else if file.Action == "delete" || file.Action == "move/delete" || file.Action == "purge" {
continue
} else {
files = append(files, file)
}
}
return
}
func (conn *Conn) FilesIncludeDeleted(paths []string) (files []*File, err error) {
var (
results []Result
)
if results, err = conn.RunMarshaled("files", paths); err != nil {
return
}
for idx := range results {
if file, ok := results[idx].(*File); !ok {
log.Printf("type translate err: %s", results[idx])
continue
} else {
files = append(files, file)
}
}
return
}