Function: url-dav-rename-file
url-dav-rename-file is a byte-compiled function defined in
url-dav.el.gz.
Signature
(url-dav-rename-file OLDNAME NEWNAME &optional OVERWRITE)
Source Code
;; Defined in /usr/src/emacs/lisp/url/url-dav.el.gz
(defun url-dav-rename-file (oldname newname &optional overwrite)
(if (not (and (string-match url-handler-regexp oldname)
(string-match url-handler-regexp newname)))
(signal 'file-error
(list "Cannot rename between different URL backends"
oldname newname)))
(let* ((headers nil)
(props nil)
(status nil)
(directory-p (url-dav-file-directory-p oldname))
(exists-p (url-http-file-exists-p newname)))
(if (and exists-p
(or
(null overwrite)
(and (numberp overwrite)
(not (yes-or-no-p
(format "File %s already exists; rename to it anyway? "
newname))))))
(signal 'file-already-exists (list "File already exists" newname)))
;; Honor the overwrite flag...
(if overwrite (push '("Overwrite" . "T") headers))
;; Have to tell them where to copy it to!
(push (cons "Destination" newname) headers)
;; Always send a depth of -1 in case we are moving a collection.
(setq props (url-dav-request oldname "MOVE" nil nil (if directory-p -1 0)
headers))
(mapc (lambda (result)
(setq status (plist-get (cdr result) 'DAV:status))
(if (not (url-dav-http-success-p status))
(signal 'file-error (list "Renaming" oldname newname status))))
props)
t))