changeset 29111:e52d90f01f53

(make-backup-file-name-1): Replace slashes with `!' rather than `|' (which is not allowed on Windows). Replace the drive letters with a string "drive_X".
author Eli Zaretskii <eliz@gnu.org>
date Tue, 23 May 2000 13:16:42 +0000
parents c06ae9d8e6b0
children 7cbf05ba1aa3
files lisp/files.el
diffstat 1 files changed, 30 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/files.el	Tue May 23 12:22:28 2000 +0000
+++ b/lisp/files.el	Tue May 23 13:16:42 2000 +0000
@@ -2231,7 +2231,7 @@
 relative or absolute.  If it is absolute, so that all matching files
 are backed up into the same directory, the file names in this
 directory will be the full name of the file backed up with all
-directory separators changed to `|' to prevent clashes.  This will not
+directory separators changed to `!' to prevent clashes.  This will not
 work correctly if your filesystem truncates the resulting name.
 
 For the common case of all backups going into one directory, the alist
@@ -2274,7 +2274,7 @@
 (defun make-backup-file-name-1 (file)
   "Subroutine of `make-backup-file-name' and `find-backup-file-name'."
   (let ((alist backup-directory-alist)
-	elt backup-directory)
+	elt backup-directory dir-sep-string)
     (while alist
       (setq elt (pop alist))
       (if (string-match (car elt) file)
@@ -2287,14 +2287,34 @@
 	    (make-directory backup-directory 'parents)
 	  (file-error file)))
       (if (file-name-absolute-p backup-directory)
-	  ;; 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
-	    directory-sep-char ?|
-	    (replace-regexp-in-string "|" "||" file))
-	   backup-directory)
+	  (progn
+	    (when (memq system-type '(windows-nt ms-dos))
+	      ;; Normalize DOSish file names: convert all slashes to
+	      ;; directory-sep-char, downcase the drive letter, if any,
+	      ;; and replace the leading "x:" with "/drive_x".
+	      (or (file-name-absolute-p file)
+		  (setq file (expand-file-name file))) ; make defaults explicit
+	      (setq dir-sep-string (char-to-string directory-sep-char))
+	      (or (eq directory-sep-char ?/)
+		  (subst-char-in-string ?/ ?\\ file))
+	      (or (eq directory-sep-char ?\\)
+		  (subst-char-in-string ?\\ ?/ file))
+	      (if (eq (aref file 1) ?:)
+		  (setq file (concat dir-sep-string
+				     "drive_"
+				     (char-to-string (downcase (aref file 0)))
+				     (if (eq (aref file 2) directory-sep-char)
+					 ""
+				       dir-sep-string)
+				     (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
+	      directory-sep-char ?!
+	      (replace-regexp-in-string "!" "!!" file))
+	     backup-directory))
 	(expand-file-name (file-name-nondirectory file)
 			  (file-name-as-directory
 			   (expand-file-name backup-directory