Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a03a0a3645 | ||
|
|
12fe295146 | ||
|
|
8f99657223 | ||
|
|
b12f1c1b33 | ||
|
|
33816041d6 | ||
|
|
31c3cc07c7 | ||
|
|
87bbafc0c0 |
13
client.go
13
client.go
@@ -6,7 +6,9 @@ import (
|
||||
"encoding/xml"
|
||||
"io"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"os"
|
||||
pathpkg "path"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
@@ -31,6 +33,10 @@ func NewClient(uri string, user string, pw string) *Client {
|
||||
return c
|
||||
}
|
||||
|
||||
func (c *Client) SetHeader(key, value string) {
|
||||
c.headers.Add(key, value)
|
||||
}
|
||||
|
||||
func (c *Client) Connect() error {
|
||||
rs, err := c.options("/")
|
||||
if err == nil {
|
||||
@@ -84,17 +90,20 @@ func (c *Client) ReadDir(path string) ([]os.FileInfo, error) {
|
||||
|
||||
if p := getProps(r, "200"); p != nil {
|
||||
f := new(File)
|
||||
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.modified = parseModified(&p.Modified)
|
||||
|
||||
if p.Type.Local == "collection" {
|
||||
f.path += "/"
|
||||
f.size = 0
|
||||
f.modified = time.Unix(0, 0)
|
||||
f.isdir = true
|
||||
} else {
|
||||
f.size = parseInt64(&p.Size)
|
||||
f.modified = parseModified(&p.Modified)
|
||||
f.isdir = false
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user