Function: ido-file-name-all-completions
ido-file-name-all-completions is a byte-compiled function defined in
ido.el.gz.
Signature
(ido-file-name-all-completions DIR)
Documentation
Return name of all files in DIR.
Uses and updates ido-dir-file-cache.
Source Code
;; Defined in /usr/src/emacs/lisp/ido.el.gz
(defun ido-file-name-all-completions (dir)
"Return name of all files in DIR.
Uses and updates `ido-dir-file-cache'."
(cond
((ido-is-unc-root dir)
(mapcar
(lambda (host)
(if (string-match "/\\'" host) host (concat host "/")))
(ido-unc-hosts t)))
((and (numberp ido-max-dir-file-cache) (> ido-max-dir-file-cache 0)
(stringp dir) (> (length dir) 0)
(ido-may-cache-directory dir))
(let* ((cached (assoc dir ido-dir-file-cache))
(ctime (nth 1 cached))
(ftp (ido-is-ftp-directory dir))
(unc (ido-is-unc-host dir))
(attr (if (or ftp unc) nil (file-attributes dir)))
(mtime (file-attribute-modification-time attr))
valid)
(when cached ; should we use the cached entry ?
(cond
(ftp
(setq valid (and (eq (car ctime) 'ftp)
(ido-cache-ftp-valid (cdr ctime)))))
(unc
(setq valid (and (eq (car ctime) 'unc)
(ido-cache-unc-valid (cdr ctime)))))
(t
(if attr
(setq valid (time-equal-p ctime mtime)))))
(unless valid
(setq ido-dir-file-cache (delq cached ido-dir-file-cache)
cached nil)))
(unless cached
(cond
(unc
(setq mtime (cons 'unc (ido-time-stamp))))
((and ftp (file-readable-p dir))
(setq mtime (cons 'ftp (ido-time-stamp)))))
(if mtime
(setq cached (cons dir (cons mtime (ido-file-name-all-completions-1 dir)))
ido-dir-file-cache (cons cached ido-dir-file-cache)))
(if (> (length ido-dir-file-cache) ido-max-dir-file-cache)
(setcdr (nthcdr (1- ido-max-dir-file-cache) ido-dir-file-cache) nil)))
(and cached
(cdr (cdr cached)))))
(t
(ido-file-name-all-completions-1 dir))))