Set the size of the entry in List()

This commit is contained in:
Julien Laffaye
2013-02-17 10:03:46 +01:00
parent 47b339b57b
commit d69e9326f4
2 changed files with 23 additions and 11 deletions

12
ftp.go
View File

@@ -2,13 +2,13 @@ package ftp
import (
"bufio"
"errors"
"fmt"
"io"
"net"
"net/textproto"
"fmt"
"strconv"
"strings"
"errors"
)
type EntryType int
@@ -154,6 +154,14 @@ func parseListLine(line string) (*Entry, error) {
return nil, errors.New("Unknown entry type")
}
if e.Type == EntryTypeFile {
size, err := strconv.ParseUint(fields[4], 10, 0)
if err != nil {
return nil, err
}
e.Size = size
}
e.Name = strings.Join(fields[8:], " ")
return e, nil
}