-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnode.go
52 lines (44 loc) · 945 Bytes
/
node.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
package ftpTreeBuilder
import (
//"github.com/dutchcoders/goftp"
"path/filepath"
"github.com/jinzhu/gorm"
)
const (
NodeTypeFolder = 1
NodeTypeArchive = 2
NodeTypeXML = 3
)
// FTPNode узел с содержимым
type FTPNode struct {
gorm.Model
tree *Tree
Path string `gorm:"unique_index"`
NodeType uint
ErrorText string
Children []*FTPNode
Downloaded uint8
Sort uint8
}
// Name returns node name
func (n FTPNode) Name() string {
if n.Path == "/" {
return n.Path
}
_, f := filepath.Split(n.Path)
return f
}
// Walk Обходит все дерево и выполняет над каждым узлом wf
// func (c *FTPNode) Walk(wf func(content *FTPNode, ftp *goftp.FTP) error) error {
// err := wf(c)
// if err != nil {
// return err
// }
// for _, child := range c.Children {
// err = child.Walk(wf)
// if err != nil {
// return err
// }
// }
// return nil
// }