From 7bbfa218f9c33ad946822aac2ee4b1f23164b59c Mon Sep 17 00:00:00 2001 From: vahid-sohrabloo Date: Sun, 19 Feb 2017 17:14:20 +0330 Subject: [PATCH] Add Size Command --- ftp.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/ftp.go b/ftp.go index 81c04db..219d987 100644 --- a/ftp.go +++ b/ftp.go @@ -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. //