2016-07-07 02:59:55 +08:00
|
|
|
package sftp
|
|
|
|
|
2016-07-09 05:13:03 +08:00
|
|
|
import (
|
|
|
|
"io"
|
|
|
|
"os"
|
|
|
|
)
|
2016-07-09 03:38:35 +08:00
|
|
|
|
2016-07-09 05:13:03 +08:00
|
|
|
// Interfaces are differentiated based on required returned values.
|
|
|
|
// All input arguments are to be pulled from Request (the only arg).
|
|
|
|
|
2016-07-26 02:42:18 +08:00
|
|
|
// FileReader should return an io.Reader for the filepath
|
2016-07-09 05:13:03 +08:00
|
|
|
type FileReader interface {
|
2016-08-03 10:37:23 +08:00
|
|
|
Fileread(Request) (io.ReaderAt, error)
|
2016-07-09 05:13:03 +08:00
|
|
|
}
|
|
|
|
|
2016-07-26 02:42:18 +08:00
|
|
|
// FileWriter should return an io.Writer for the filepath
|
2016-07-09 05:13:03 +08:00
|
|
|
type FileWriter interface {
|
2016-08-03 10:37:23 +08:00
|
|
|
Filewrite(Request) (io.WriterAt, error)
|
2016-07-09 05:13:03 +08:00
|
|
|
}
|
|
|
|
|
2016-07-26 02:42:18 +08:00
|
|
|
// FileCmder should return an error (rename, remove, setstate, etc.)
|
2016-07-09 05:13:03 +08:00
|
|
|
type FileCmder interface {
|
2016-08-03 10:37:23 +08:00
|
|
|
Filecmd(Request) error
|
2016-07-09 05:13:03 +08:00
|
|
|
}
|
|
|
|
|
2017-07-28 09:22:11 +08:00
|
|
|
// FileLister should return file info interface and errors (readdir, stat)
|
|
|
|
type FileLister interface {
|
|
|
|
Filelist(Request) (ListerAt, error)
|
|
|
|
}
|
|
|
|
|
|
|
|
// ListerAt does for file lists what io.ReaderAt does for files.
|
|
|
|
// ListerAt should return the number of entries copied and an io.EOF
|
|
|
|
// error if at end of list. This is testable by comparing how many you
|
|
|
|
// copied to how many could be copied (eg. n < len(ls) below).
|
|
|
|
// The copy() builtin is best for the copying.
|
|
|
|
type ListerAt interface {
|
|
|
|
ListAt([]os.FileInfo, int64) (int, error)
|
2016-07-09 05:13:03 +08:00
|
|
|
}
|