Fix backing up remote files in local directories on MS-Windows
* lisp/files.el (make-backup-file-name-1): Support remote file names correctly when they are backed up into a local directory on MS-Windows and MS-DOS. (Bug#29440)
This commit is contained in:
parent
7e61e74da7
commit
66ec92af00
1 changed files with 29 additions and 19 deletions
|
@ -4653,25 +4653,35 @@ The function `find-backup-file-name' also uses this."
|
||||||
;; "/drive_x".
|
;; "/drive_x".
|
||||||
(or (file-name-absolute-p file)
|
(or (file-name-absolute-p file)
|
||||||
(setq file (expand-file-name file))) ; make defaults explicit
|
(setq file (expand-file-name file))) ; make defaults explicit
|
||||||
;; Replace any invalid file-name characters (for the
|
(cond
|
||||||
;; case of backing up remote files).
|
((file-remote-p file)
|
||||||
(setq file (expand-file-name (convert-standard-filename file)))
|
;; Remove the leading slash, if any, to prevent
|
||||||
(if (eq (aref file 1) ?:)
|
;; convert-standard-filename from converting that to a
|
||||||
(setq file (concat "/"
|
;; backslash.
|
||||||
"drive_"
|
(and (memq (aref file 0) '(?/ ?\\))
|
||||||
(char-to-string (downcase (aref file 0)))
|
(setq file (substring file 1)))
|
||||||
(if (eq (aref file 2) ?/)
|
;; Replace any invalid file-name characters, then
|
||||||
""
|
;; prepend the leading slash back.
|
||||||
"/")
|
(setq file (concat "/" (convert-standard-filename file))))
|
||||||
(substring file 2)))))
|
(t
|
||||||
;; Make the name unique by substituting directory
|
;; Replace any invalid file-name characters.
|
||||||
;; separators. It may not really be worth bothering about
|
(setq file (expand-file-name (convert-standard-filename file)))
|
||||||
;; doubling `!'s in the original name...
|
(if (eq (aref file 1) ?:)
|
||||||
(expand-file-name
|
(setq file (concat "/"
|
||||||
(subst-char-in-string
|
"drive_"
|
||||||
?/ ?!
|
(char-to-string (downcase (aref file 0)))
|
||||||
(replace-regexp-in-string "!" "!!" file))
|
(if (eq (aref file 2) ?/)
|
||||||
backup-directory))
|
""
|
||||||
|
"/")
|
||||||
|
(substring file 2))))))
|
||||||
|
;; Make the name unique by substituting directory
|
||||||
|
;; separators. It may not really be worth bothering about
|
||||||
|
;; doubling `!'s in the original name...
|
||||||
|
(expand-file-name
|
||||||
|
(subst-char-in-string
|
||||||
|
?/ ?!
|
||||||
|
(replace-regexp-in-string "!" "!!" file))
|
||||||
|
backup-directory)))
|
||||||
(expand-file-name (file-name-nondirectory file)
|
(expand-file-name (file-name-nondirectory file)
|
||||||
(file-name-as-directory abs-backup-directory))))))
|
(file-name-as-directory abs-backup-directory))))))
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue