fix slashes
This commit is contained in:
parent
d4b8ebb4b2
commit
7caa8c8b7d
@ -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{}) {
|
||||||
|
@ -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)
|
||||||
}
|
}
|
||||||
|
7
utils.go
7
utils.go
@ -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, "/")
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user