Function: tramp-adb-handle-copy-file
tramp-adb-handle-copy-file is a byte-compiled function defined in
tramp-adb.el.gz.
Signature
(tramp-adb-handle-copy-file FILENAME NEWNAME &optional OK-IF-ALREADY-EXISTS KEEP-DATE PRESERVE-UID-GID PRESERVE-EXTENDED-ATTRIBUTES)
Documentation
Like copy-file for Tramp files.
PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are completely ignored.
Source Code
;; Defined in /usr/src/emacs/lisp/net/tramp-adb.el.gz
(defun tramp-adb-handle-copy-file
(filename newname &optional ok-if-already-exists keep-date
_preserve-uid-gid _preserve-extended-attributes)
"Like `copy-file' for Tramp files.
PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are completely ignored."
(setq filename (expand-file-name filename)
newname (expand-file-name newname))
(if (file-directory-p filename)
(copy-directory filename newname keep-date t)
(let ((t1 (tramp-tramp-file-p filename))
(t2 (tramp-tramp-file-p newname))
;; We don't want the target file to be compressed, so we
;; let-bind `jka-compr-inhibit' to t.
(jka-compr-inhibit t))
(with-parsed-tramp-file-name (if t1 filename newname) nil
(tramp-barf-if-file-missing v filename
(when (and (not ok-if-already-exists) (file-exists-p newname))
(tramp-error v 'file-already-exists newname))
(when (and (file-directory-p newname)
(not (directory-name-p newname)))
(tramp-error v 'file-error "File is a directory %s" newname))
(with-tramp-progress-reporter
v 0 (format "Copying %s to %s" filename newname)
(if (and t1 t2 (tramp-equal-remote filename newname))
(let ((l1 (tramp-file-local-name filename))
(l2 (tramp-file-local-name newname)))
;; We must also flush the cache of the directory,
;; because `file-attributes' reads the values from
;; there.
(tramp-flush-file-properties v l2)
;; Short track.
(tramp-adb-barf-unless-okay
v (format
"cp -f %s %s"
(tramp-shell-quote-argument l1)
(tramp-shell-quote-argument l2))
"Error copying %s to %s" filename newname))
(if-let* ((tmpfile (file-local-copy filename)))
;; Remote filename.
(condition-case err
(rename-file tmpfile newname ok-if-already-exists)
((error quit)
(delete-file tmpfile)
(signal (car err) (cdr err))))
;; Remote newname.
(when (and (file-directory-p newname)
(directory-name-p newname))
(setq newname
(expand-file-name
(file-name-nondirectory filename) newname)))
(with-parsed-tramp-file-name newname nil
(when (and (not ok-if-already-exists)
(file-exists-p newname))
(tramp-error v 'file-already-exists newname))
;; We must also flush the cache of the directory,
;; because `file-attributes' reads the values from
;; there.
(tramp-flush-file-properties v localname)
(unless (tramp-adb-execute-adb-command
v "push"
(file-name-unquote filename)
(file-name-unquote localname))
(tramp-error
v 'file-error
"Cannot copy `%s' `%s'" filename newname)))))))))
;; KEEP-DATE handling.
(when keep-date
(tramp-compat-set-file-times
newname
(file-attribute-modification-time (file-attributes filename))
(unless ok-if-already-exists 'nofollow)))))