Function: comp-delete-or-replace-file
comp-delete-or-replace-file is a byte-compiled function defined in
comp.el.gz.
Signature
(comp-delete-or-replace-file OLDFILE &optional NEWFILE)
Documentation
Replace OLDFILE with NEWFILE.
When NEWFILE is nil just delete OLDFILE. Takes the necessary steps when dealing with OLDFILE being a shared library that might be currently loaded into a running Emacs session.
Source Code
;; Defined in /usr/src/emacs/lisp/emacs-lisp/comp.el.gz
(defun comp-delete-or-replace-file (oldfile &optional newfile)
"Replace OLDFILE with NEWFILE.
When NEWFILE is nil just delete OLDFILE.
Takes the necessary steps when dealing with OLDFILE being a
shared library that might be currently loaded into a running Emacs
session."
(cond ((eq 'windows-nt system-type)
(ignore-errors (delete-file oldfile))
(while
(condition-case _
(progn
;; oldfile maybe recreated by another Emacs in
;; between the following two rename-file calls
(if (file-exists-p oldfile)
(rename-file oldfile (make-temp-file-internal
(file-name-sans-extension oldfile)
nil ".eln.old" nil)
t))
(when newfile
(rename-file newfile oldfile nil))
;; Keep on trying.
nil)
(file-already-exists
;; Done
t))))
;; Remove the old eln instead of copying the new one into it
;; to get a new inode and prevent crashes in case the old one
;; is currently loaded.
(t (delete-file oldfile)
(when newfile
(rename-file newfile oldfile)))))