add Rename and Copy

This commit is contained in:
Christoph Polcin
2014-10-24 14:08:42 +02:00
parent e02560544b
commit 47076d6487
3 changed files with 51 additions and 0 deletions

View File

@@ -84,3 +84,30 @@ func (c *Client) propfind(path string, self bool, body string, resp interface{},
return parseXML(rs.Body, resp, parse)
}
func (c *Client) copymove(method string, oldpath string, newpath string, overwrite bool) error {
rq, err := c.req(method, oldpath, nil)
if err != nil {
return newPathErrorErr(method, oldpath, err)
}
rq.Header.Add("Destination", Join(c.root, newpath))
if overwrite {
rq.Header.Add("Overwrite", "T")
} else {
rq.Header.Add("Overwrite", "F")
}
rs, err := c.c.Do(rq)
if err != nil {
return newPathErrorErr(method, oldpath, err)
}
defer rs.Body.Close()
switch rs.StatusCode {
case 201, 204:
return nil
}
return newPathError(method, oldpath, rs.StatusCode)
}