add initial source

This commit is contained in:
Christoph Polcin
2014-10-23 10:39:55 +02:00
parent a224ac9c70
commit 95f1f68142
6 changed files with 340 additions and 0 deletions

33
utils.go Normal file
View File

@@ -0,0 +1,33 @@
package gowebdav
import (
"bytes"
"io"
"strconv"
"strings"
"time"
)
func Join(path0 string, path1 string) string {
return strings.TrimSuffix(path0, "/") + "/" + strings.TrimPrefix(path1, "/")
}
func String(r io.Reader) string {
buf := new(bytes.Buffer)
buf.ReadFrom(r)
return buf.String()
}
func parseUint(s *string) uint {
if n, e := strconv.ParseUint(*s, 10, 32); e == nil {
return uint(n)
}
return 0
}
func parseModified(s *string) time.Time {
if t, e := time.Parse(time.RFC1123, *s); e == nil {
return t
}
return time.Unix(0, 0)
}