1package sftp 2 3import ( 4 "io" 5 "os" 6) 7 8// Interfaces are differentiated based on required returned values. 9// All input arguments are to be pulled from Request (the only arg). 10 11// The Handler interfaces all take the Request object as its only argument. 12// All the data you should need to handle the call are in the Request object. 13// The request.Method attribute is initially the most important one as it 14// determines which Handler gets called. 15 16// FileReader should return an io.ReaderAt for the filepath 17// Note in cases of an error, the error text will be sent to the client. 18// Called for Methods: Get 19type FileReader interface { 20 Fileread(*Request) (io.ReaderAt, error) 21} 22 23// FileWriter should return an io.WriterAt for the filepath. 24// 25// The request server code will call Close() on the returned io.WriterAt 26// ojbect if an io.Closer type assertion succeeds. 27// Note in cases of an error, the error text will be sent to the client. 28// Called for Methods: Put, Open 29type FileWriter interface { 30 Filewrite(*Request) (io.WriterAt, error) 31} 32 33// FileCmder should return an error 34// Note in cases of an error, the error text will be sent to the client. 35// Called for Methods: Setstat, Rename, Rmdir, Mkdir, Symlink, Remove 36type FileCmder interface { 37 Filecmd(*Request) error 38} 39 40// FileLister should return an object that fulfils the ListerAt interface 41// Note in cases of an error, the error text will be sent to the client. 42// Called for Methods: List, Stat, Readlink 43type FileLister interface { 44 Filelist(*Request) (ListerAt, error) 45} 46 47// ListerAt does for file lists what io.ReaderAt does for files. 48// ListAt should return the number of entries copied and an io.EOF 49// error if at end of list. This is testable by comparing how many you 50// copied to how many could be copied (eg. n < len(ls) below). 51// The copy() builtin is best for the copying. 52// Note in cases of an error, the error text will be sent to the client. 53type ListerAt interface { 54 ListAt([]os.FileInfo, int64) (int, error) 55} 56