Function: f-copy

f-copy is a byte-compiled function defined in f.el.

Signature

(f-copy FROM TO)

Documentation

Copy file or directory FROM to TO.

If FROM names a directory and TO is a directory name, copy FROM into TO as a subdirectory.

Source Code

;; Defined in ~/.emacs.d/elpa/f-20241003.1131/f.el
(defun f-copy (from to)
  "Copy file or directory FROM to TO.
If FROM names a directory and TO is a directory name, copy FROM
into TO as a subdirectory."
  (f--destructive to
    (if (f-file-p from)
        (copy-file from to)
      ;; The behavior of `copy-directory' differs between Emacs 23 and
      ;; 24 in that in Emacs 23, the contents of `from' is copied to
      ;; `to', while in Emacs 24 the directory `from' is copied to
      ;; `to'. We want the Emacs 24 behavior.
      (if (> emacs-major-version 23)
          (copy-directory from to)
        (if (f-dir-p to)
            (progn
              (apply 'f-mkdir (f-split to))
              (let ((new-to (f-expand (f-filename from) to)))
                (copy-directory from new-to)))
          (copy-directory from to))))))