forked from yob/graval
-
Notifications
You must be signed in to change notification settings - Fork 1
/
ftpfileinfo.go
58 lines (48 loc) · 1.14 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
package graval
import (
"os"
"time"
)
type ftpFileInfo struct {
name string
bytes int64
mode os.FileMode
}
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 time.Now()
}
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) os.FileInfo {
d := new(ftpFileInfo)
d.name = name
d.bytes = int64(0)
d.mode = os.ModeDir | 666
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 int) os.FileInfo {
f := new(ftpFileInfo)
f.name = name
f.bytes = int64(bytes)
f.mode = 666
return f
}