Documentation ¶
Overview ¶
Package tinyftp implements a small subset of FTP, enough to retrieve directory listings and files (including resume support). It uses net/textproto to do the heavy lifting. Most of the functions return the triple code, message, err besides the real result. if err == nil, code and message return the raw informal FTP server code and message for the success case.
Index ¶
- type Conn
- func (c *Conn) AuthSSL(mode string) (code int, message string, err error)
- func (c *Conn) Close() error
- func (c *Conn) Cmd(expectCode int, format string, args ...interface{}) (code int, message string, err error)
- func (c *Conn) Cwd(dir string) (code int, message string, err error)
- func (c *Conn) List(dir string, dconn net.Conn) (dirList []string, code int, message string, err error)
- func (c *Conn) Login(user, pass string) (code int, message string, err error)
- func (c *Conn) NameList(dir string, dconn net.Conn) (dirList []string, code int, message string, err error)
- func (c *Conn) Passive() (addr string, code int, message string, err error)
- func (c *Conn) Quit() (code int, message string, err error)
- func (c *Conn) Rest(size int64) (code int, message string, err error)
- func (c *Conn) Retrieve(fname string, dconn net.Conn) (contents []byte, code int, message string, err error)
- func (c *Conn) RetrieveTo(fname string, dconn net.Conn, w io.Writer) (written int64, code int, message string, err error)
- func (c *Conn) Size(fname string) (size int64, code int, message string, err error)
- func (c *Conn) SwitchTo(nconn io.ReadWriteCloser)
- func (c *Conn) Type(mode string) (code int, message string, err error)
- func (c *Conn) Upload(fname string, dconn net.Conn, contents []byte) (written int64, code int, message string, err error)
- func (c *Conn) UploadFrom(fname string, dconn net.Conn, r io.Reader) (written int64, code int, message string, err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Conn ¶
type Conn struct {
// contains filtered or unexported fields
}
func Dial ¶
Dial connects to the given address on the given network using net.Dial and then returns a new Conn for the connection.
func DialTimeout ¶
func DialTimeout(network, addr string, timeout time.Duration) (conn *Conn, code int, message string, err error)
DialTimeout connects to the given address on the given network with a timeout and then returns a new Conn for the connection.
func (*Conn) Cmd ¶
func (c *Conn) Cmd(expectCode int, format string, args ...interface{}) (code int, message string, err error)
Send an FTP command and return the response code and message. The expectCode is given as argument to textproto.ReadResponse to signify the expected FTP response code.
func (*Conn) List ¶
func (c *Conn) List(dir string, dconn net.Conn) (dirList []string, code int, message string, err error)
List the specified directory.
func (*Conn) Login ¶
Authenticate the session using the given user name and password. Use anonymous@ if they are empty.
func (*Conn) NameList ¶
func (c *Conn) NameList(dir string, dconn net.Conn) (dirList []string, code int, message string, err error)
List the specified directory, names only.
func (*Conn) Retrieve ¶
func (c *Conn) Retrieve(fname string, dconn net.Conn) (contents []byte, code int, message string, err error)
Retrieve the named file
func (*Conn) RetrieveTo ¶
func (c *Conn) RetrieveTo(fname string, dconn net.Conn, w io.Writer) (written int64, code int, message string, err error)
Retrieve the named file to the given io.Writer.
func (*Conn) SwitchTo ¶
func (c *Conn) SwitchTo(nconn io.ReadWriteCloser)
Switch underlaying connection to a new instance. (Necessary to handle SSL/TLS connections for explicit FTPS servers)