-
Notifications
You must be signed in to change notification settings - Fork 31
/
ftpfileinfo.go
61 lines (51 loc) · 1.23 KB
/
ftpfileinfo.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
59
60
61
package graval
import (
"os"
"time"
)
type ftpFileInfo struct {
name string
bytes int64
mode os.FileMode
modtime time.Time
}
func (info *ftpFileInfo) Name() string {
return info.name
}
func (info *ftpFileInfo) Size() int64 {
return info.bytes
}
func (info *ftpFileInfo) Mode() os.FileMode {
return info.mode
}
func (info *ftpFileInfo) ModTime() time.Time {
return info.modtime
}
func (info *ftpFileInfo) IsDir() bool {
return (info.mode & os.ModeDir) == os.ModeDir
}
func (info *ftpFileInfo) Sys() interface{} {
return nil
}
// NewDirItem creates a new os.FileInfo that represents a single diretory. Use
// this function to build the response to DirContents() in your FTPDriver
// implementation.
func NewDirItem(name string, modtime time.Time) os.FileInfo {
d := new(ftpFileInfo)
d.name = name
d.bytes = int64(0)
d.mode = os.ModeDir | 0666
d.modtime = modtime
return d
}
// NewFileItem creates a new os.FileInfo that represents a single file. Use
// this function to build the response to DirContents() in your FTPDriver
// implementation.
func NewFileItem(name string, bytes int64, modtime time.Time) os.FileInfo {
f := new(ftpFileInfo)
f.name = name
f.bytes = int64(bytes)
f.mode = 0666
f.modtime = modtime
return f
}