Function: eshell-split-filename
eshell-split-filename is a byte-compiled function defined in
esh-util.el.gz.
Signature
(eshell-split-filename FILENAME)
Documentation
Split a FILENAME into a list of file/directory components.
Aliases
eshell-split-path (obsolete since 30.1)
Source Code
;; Defined in /usr/src/emacs/lisp/eshell/esh-util.el.gz
(defun eshell-split-filename (filename)
"Split a FILENAME into a list of file/directory components."
(let* ((remote (file-remote-p filename))
(filename (file-local-name filename))
(len (length filename))
(index 0) (curr-start 0)
parts)
(when (and (eshell-under-windows-p)
(string-prefix-p "//" filename))
(setq index 2))
(while (< index len)
(when (eq (aref filename index) ?/)
(push (if (= curr-start index) "/"
(substring filename curr-start (1+ index)))
parts)
(setq curr-start (1+ index)))
(setq index (1+ index)))
(when (< curr-start len)
(push (substring filename curr-start) parts))
(setq parts (nreverse parts))
(when (and (eshell-under-windows-p)
(string-match "\\`[A-Za-z]:\\'" (car parts)))
(setcar parts (concat (car parts) "/")))
(if remote (cons remote parts) parts)))