This repository has been archived by the owner on Jul 8, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 138
/
driver.go
61 lines (48 loc) · 2.04 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
// Copyright 2018 The goftp Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
package server
import "io"
// DriverFactory is a driver factory to create driver. For each client that connects to the server, a new FTPDriver is required.
// Create an implementation if this interface and provide it to FTPServer.
type DriverFactory interface {
NewDriver() (Driver, error)
}
// Driver is an interface that you will create an implementation that speaks to your
// chosen persistence layer. graval will create a new instance of your
// driver for each client that connects and delegate to it as required.
type Driver interface {
// Init init
Init(*Conn)
// params - a file path
// returns - a time indicating when the requested path was last modified
// - an error if the file doesn't exist or the user lacks
// permissions
Stat(string) (FileInfo, error)
// params - path
// returns - true if the current user is permitted to change to the
// requested path
ChangeDir(string) error
// params - path, function on file or subdir found
// returns - error
// path
ListDir(string, func(FileInfo) error) error
// params - path
// returns - nil if the directory was deleted or any error encountered
DeleteDir(string) error
// params - path
// returns - nil if the file was deleted or any error encountered
DeleteFile(string) error
// params - from_path, to_path
// returns - nil if the file was renamed or any error encountered
Rename(string, string) error
// params - path
// returns - nil if the new directory was created or any error encountered
MakeDir(string) error
// params - path
// returns - a string containing the file data to send to the client
GetFile(string, int64) (int64, io.ReadCloser, error)
// params - destination path, an io.Reader containing the file data
// returns - the number of bytes writen and the first error encountered while writing, if any.
PutFile(string, io.Reader, bool) (int64, error)
}