Add Size Command

This commit is contained in:
vahid-sohrabloo 2017-02-19 17:14:20 +03:30 committed by GitHub
parent de604c9776
commit 7bbfa218f9

15
ftp.go
View File

@ -407,6 +407,21 @@ func (c *ServerConn) CurrentDir() (string, error) {
return msg[start+1 : end], nil
}
// FileSize issues a SIZE FTP command, which Returns the size of the file
func (c *ServerConn) FileSize(path string) (int, error) {
_, msg, err := c.cmd(StatusFile, "SIZE %s", path)
if err != nil {
return 0, err
}
size, err := strconv.Atoi(msg)
if err != nil {
return 0, err
}
return size, nil
}
// Retr issues a RETR FTP command to fetch the specified file from the remote
// FTP server.
//