More commands and their tests.

Delete()
MakeDir()
RemoveDir()
This commit is contained in:
jlaffaye 2011-09-06 00:02:01 +02:00
parent a87255661d
commit b70c76ed28
2 changed files with 39 additions and 3 deletions

View File

@ -51,5 +51,20 @@ func TestConn(t *testing.T) {
r.Close()
}
err = c.Delete("tset")
if err != nil {
t.Error(err)
}
err = c.MakeDir("mydir")
if err != nil {
t.Error(err)
}
err = c.RemoveDir("mydir")
if err != nil {
t.Error(err)
}
c.Quit()
}

27
ftp.go
View File

@ -259,13 +259,34 @@ func (c *ServerConn) Rename(from, to string) os.Error {
return err
}
func (c *ServerConn) Delete(name string) os.Error {
_, err := c.conn.Cmd("DELE %s", name)
if err != nil {
return err
}
_, _, err = c.conn.ReadCodeLine(StatusRequestedFileActionOK)
return err
}
func (c *ServerConn) MakeDir(name string) os.Error {
// todo
return nil
_, err := c.conn.Cmd("MKD %s", name)
if err != nil {
return err
}
_, _, err = c.conn.ReadCodeLine(StatusPathCreated)
return err
}
func (c *ServerConn) RemoveDir(name string) os.Error {
return nil
_, err := c.conn.Cmd("RMD %s", name)
if err != nil {
return err
}
_, _, err = c.conn.ReadCodeLine(StatusRequestedFileActionOK)
return err
}
// Sends a NOOP command. Usualy used to prevent timeouts.