-
Notifications
You must be signed in to change notification settings - Fork 0
/
driver.go
executable file
·83 lines (61 loc) · 1.53 KB
/
driver.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
package ftpdriver
import (
//"errors"
"fmt"
"io"
"github.com/dutchcoders/goftp"
"github.com/goftp/server"
)
type FtpDriver struct {
server string
ftp *goftp.FTP
}
func (driver *FtpDriver) Init(conn *server.Conn) {
//driver.conn = conn
}
func (driver *FtpDriver) ChangeDir(path string) error {
return nil
}
func (driver *FtpDriver) Stat(key string) (server.FileInfo, error) {
return nil, nil
}
func (driver *FtpDriver) ListDir(prefix string, callback func(server.FileInfo) error) error {
return nil
}
func (driver *FtpDriver) DeleteDir(key string) error {
return nil
}
func (driver *FtpDriver) DeleteFile(key string) error {
return nil
}
func (driver *FtpDriver) Rename(keySrc, keyDest string) error {
fmt.Println("rename from", keySrc, keyDest)
return nil
}
func (driver *FtpDriver) MakeDir(path string) error {
return nil
}
func (driver *FtpDriver) GetFile(key string, offset int64) (int64, io.ReadCloser, error) {
return 0, nil, nil
}
func (driver *FtpDriver) PutFile(key string, data io.Reader, appendData bool) (int64, error) {
return 0, nil
}
type FtpDriverFactory struct {
host string
port string
user string
pass string
}
func NewFtpDriverFactory(host, port, user, pass string) server.DriverFactory {
return &FtpDriverFactory{host, port, user, pass}
}
func (factory *FtpDriverFactory) NewDriver() (server.Driver, error) {
var server = factory.host + ":" + factory.port
var ftp *goftp.FTP
var err error
if ftp, err = goftp.Connect(server); err != nil {
return nil, err
}
return &FtpDriver{server, ftp}, nil
}