Function: w32-convert-standard-filename

w32-convert-standard-filename is a byte-compiled function defined in w32-fns.el.gz.

Signature

(w32-convert-standard-filename FILENAME)

Documentation

Convert a standard file's name to something suitable for MS-Windows.

This means to guarantee valid names and perhaps to canonicalize certain patterns.

This function is called by convert-standard-filename.

Replace invalid characters and turn Cygwin names into native names.

Source Code

;; Defined in /usr/src/emacs/lisp/w32-fns.el.gz
;;;; Standard filenames

(defun w32-convert-standard-filename (filename)
  "Convert a standard file's name to something suitable for MS-Windows.
This means to guarantee valid names and perhaps to canonicalize
certain patterns.

This function is called by `convert-standard-filename'.

Replace invalid characters and turn Cygwin names into native
names."
  (save-match-data
    (let ((name
	   (if (string-match "\\`/cygdrive/\\([a-zA-Z]\\)/" filename)
               (replace-match "\\1:/" t nil filename)
             (copy-sequence filename)))
	  (start 0))
      ;; leave ':' if part of drive specifier
      (if (and (> (length name) 1)
	       (eq (aref name 1) ?:))
	  (setq start 2))
      ;; destructively replace invalid filename characters with !
      (while (string-match "[?*:<>|\"\000-\037]" name start)
	(aset name (match-beginning 0) ?!)
	(setq start (match-end 0)))
      name)))