Add SetUTF8()

This commit is contained in:
zeast 2017-01-04 17:59:52 +08:00
parent 95f4fe9d35
commit eb716a85b9

26
ftp.go
View File

@ -687,6 +687,32 @@ func (c *ServerConn) Quit() error {
return c.conn.Close() return c.conn.Close()
} }
// SetUTF8 issues a OPTS UTF8 ON/OFF command.
func (c *ServerConn) SetUTF8(on bool) error {
var code int
var message string
var err error
if on {
code, message, err = c.cmd(-1, "OPTS UTF8 ON")
} else {
code, message, err = c.cmd(-1, "OPTS UTF8 OFF")
}
if err != nil {
return err
}
switch code {
case StatusCommandOK:
return nil
default:
return errors.New(message)
}
}
// Read implements the io.Reader interface on a FTP data connection. // Read implements the io.Reader interface on a FTP data connection.
func (r *response) Read(buf []byte) (int, error) { func (r *response) Read(buf []byte) (int, error) {
return r.conn.Read(buf) return r.conn.Read(buf)