fix slashes

This commit is contained in:
Christoph Polcin 2014-10-23 14:26:08 +02:00
parent d4b8ebb4b2
commit 7caa8c8b7d
3 changed files with 9 additions and 2 deletions

View File

@ -69,7 +69,7 @@ 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) path = FixSlashes(path)
files := make([]os.FileInfo, 0) files := make([]os.FileInfo, 0)
skipSelf := true skipSelf := true
parse := func(resp interface{}) { parse := func(resp interface{}) {

View File

@ -39,7 +39,7 @@ func main() {
switch *m { switch *m {
case "LIST", "PROPFIND": case "LIST", "PROPFIND":
if files, err := c.ReadDir(path); err == nil { if files, err := c.ReadDir(path); err == nil {
fmt.Println(len(files)) fmt.Println(fmt.Sprintf("Resources: %d - %s", len(files), path))
for _, f := range files { for _, f := range files {
fmt.Println(f) fmt.Println(f)
} }

View File

@ -23,6 +23,13 @@ func FixSlash(s string) string {
return s return s
} }
func FixSlashes(s string) string {
if s[0] != '/' {
s = "/" + s
}
return FixSlash(s)
}
func Join(path0 string, path1 string) string { func Join(path0 string, path1 string) string {
return strings.TrimSuffix(path0, "/") + "/" + strings.TrimPrefix(path1, "/") return strings.TrimSuffix(path0, "/") + "/" + strings.TrimPrefix(path1, "/")
} }