5 Commits
0 ... 1

Author SHA1 Message Date
Christoph Polcin
8f99657223 client: dry 2015-12-09 10:02:37 +01:00
Christoph Polcin
b12f1c1b33 Merge pull request #2 from mattn/handle-href
look href if displayname not exists

thanks!
2015-12-09 09:56:31 +01:00
Yasuhiro Matsumoto
33816041d6 Use href instead of displayname for Name() 2015-12-09 17:35:24 +09:00
Christoph Polcin
31c3cc07c7 Merge pull request #1 from mattn/fix-directory-timestamp
directory should have mod-time
2015-12-09 09:32:20 +01:00
Yasuhiro Matsumoto
87bbafc0c0 directory should have mod-time 2015-11-16 22:41:20 +09:00

View File

@@ -6,7 +6,9 @@ import (
"encoding/xml" "encoding/xml"
"io" "io"
"net/http" "net/http"
"net/url"
"os" "os"
pathpkg "path"
"strings" "strings"
"time" "time"
) )
@@ -84,17 +86,20 @@ func (c *Client) ReadDir(path string) ([]os.FileInfo, error) {
if p := getProps(r, "200"); p != nil { if p := getProps(r, "200"); p != nil {
f := new(File) f := new(File)
f.name = p.Name if ps, err := url.QueryUnescape(r.Href); err == nil {
f.name = pathpkg.Base(ps)
} else {
f.name = p.Name
}
f.path = path + f.name f.path = path + f.name
f.modified = parseModified(&p.Modified)
if p.Type.Local == "collection" { if p.Type.Local == "collection" {
f.path += "/" f.path += "/"
f.size = 0 f.size = 0
f.modified = time.Unix(0, 0)
f.isdir = true f.isdir = true
} else { } else {
f.size = parseInt64(&p.Size) f.size = parseInt64(&p.Size)
f.modified = parseModified(&p.Modified)
f.isdir = false f.isdir = false
} }