set File.path

This commit is contained in:
Christoph Polcin 2014-10-23 13:38:16 +02:00
parent 735efcad06
commit a13166c6af

View File

@ -69,15 +69,17 @@ func getProps(r *response, status string) *props {
} }
func (c *Client) ReadDir(path string) ([]os.FileInfo, error) { func (c *Client) ReadDir(path string) ([]os.FileInfo, error) {
path = FixSlash(path)
files := make([]os.FileInfo, 0) files := make([]os.FileInfo, 0)
parse := func(resp interface{}) { parse := func(resp interface{}) {
r := resp.(*response) r := resp.(*response)
if p := getProps(r, "200"); p != nil { if p := getProps(r, "200"); p != nil {
f := new(File) f := new(File)
f.path = "/TODO/"
f.name = p.Name f.name = p.Name
f.path = path + f.name
if p.Type.Local == "collection" { if p.Type.Local == "collection" {
f.path += "/"
f.size = 0 f.size = 0
f.modified = time.Unix(0, 0) f.modified = time.Unix(0, 0)
f.isdir = true f.isdir = true
@ -88,11 +90,12 @@ func (c *Client) ReadDir(path string) ([]os.FileInfo, error) {
} }
files = append(files, *f) files = append(files, *f)
r.Props = nil
}
} }
err := c.Propfind(FixSlash(path), false, r.Props = nil
}
err := c.Propfind(path, false,
`<d:propfind xmlns:d='DAV:'> `<d:propfind xmlns:d='DAV:'>
<d:prop> <d:prop>
<d:displayname/> <d:displayname/>