Function: tramp-handle-file-name-case-insensitive-p
tramp-handle-file-name-case-insensitive-p is a byte-compiled function
defined in tramp.el.gz.
Signature
(tramp-handle-file-name-case-insensitive-p FILENAME)
Documentation
Like file-name-case-insensitive-p for Tramp files.
Source Code
;; Defined in /usr/src/emacs/lisp/net/tramp.el.gz
(defun tramp-handle-file-name-case-insensitive-p (filename)
"Like `file-name-case-insensitive-p' for Tramp files."
;; We make it a connection property, assuming that all file systems
;; on the remote host behave similar. This might be wrong for
;; mounted NFS directories or SMB/AFP shares; such more granular
;; tests will be added in case they are needed.
(setq filename (expand-file-name filename))
(with-parsed-tramp-file-name filename nil
(or ;; Maybe there is a default value.
(tramp-get-method-parameter v 'tramp-case-insensitive)
;; There isn't. So we must check, in case there's a connection already.
(and (let ((non-essential t)) (tramp-connectable-p v))
(with-tramp-connection-property v "case-insensitive"
(ignore-errors
(with-tramp-progress-reporter v 5 "Checking case-insensitive"
;; The idea is to compare a file with lower case
;; letters with the same file with upper case letters.
(let ((candidate (directory-file-name filename))
case-fold-search
tmpfile)
;; Check, whether we find an existing file with
;; lower case letters. This avoids us to create a
;; temporary file.
(while (and (string-match-p
(rx lower) (tramp-file-local-name candidate))
(not (file-exists-p candidate)))
(setq candidate
(directory-file-name
(file-name-directory candidate))))
;; Nothing found, so we must use a temporary file
;; for comparison.
(unless (string-match-p
(rx lower) (tramp-file-local-name candidate))
(setq tmpfile
(let ((default-directory
(file-name-directory filename)))
(make-nearby-temp-file "tramp."))
candidate tmpfile))
;; Check for the existence of the same file with
;; upper case letters.
(unwind-protect
(file-exists-p
(concat
(file-remote-p candidate)
(upcase (tramp-file-local-name candidate))))
;; Cleanup.
(when tmpfile (delete-file tmpfile)))))))))))