Function: tramp-adb-handle-directory-files-and-attributes
tramp-adb-handle-directory-files-and-attributes is a byte-compiled
function defined in tramp-adb.el.gz.
Signature
(tramp-adb-handle-directory-files-and-attributes DIRECTORY &optional FULL MATCH NOSORT ID-FORMAT COUNT)
Documentation
Like directory-files-and-attributes for Tramp files.
Source Code
;; Defined in /usr/src/emacs/lisp/net/tramp-adb.el.gz
(defun tramp-adb-handle-directory-files-and-attributes
(directory &optional full match nosort id-format count)
"Like `directory-files-and-attributes' for Tramp files."
(unless (file-exists-p directory)
(tramp-compat-file-missing (tramp-dissect-file-name directory) directory))
(when (file-directory-p directory)
(with-parsed-tramp-file-name (expand-file-name directory) nil
(copy-tree
(with-tramp-file-property
v localname (format "directory-files-and-attributes-%s-%s-%s-%s-%s"
full match id-format nosort count)
(with-current-buffer (tramp-get-buffer v)
(when (tramp-adb-send-command-and-check
v (format "%s -a -l %s"
(tramp-adb-get-ls-command v)
(tramp-shell-quote-argument localname)))
;; We insert also filename/. and filename/.., because "ls" doesn't.
;; Looks like it does include them in toybox, since Android 6.
(unless (re-search-backward "\\.$" nil t)
(narrow-to-region (point-max) (point-max))
(tramp-adb-send-command
v (format "%s -d -a -l %s %s"
(tramp-adb-get-ls-command v)
(tramp-shell-quote-argument
(tramp-compat-file-name-concat localname "."))
(tramp-shell-quote-argument
(tramp-compat-file-name-concat localname ".."))))
(widen)))
(tramp-adb-sh-fix-ls-output)
(let ((result (tramp-do-parse-file-attributes-with-ls
v (or id-format 'integer))))
(when full
(setq result
(mapcar
(lambda (x)
(cons (expand-file-name (car x) directory) (cdr x)))
result)))
(unless nosort
(setq result
(sort result (lambda (x y) (string< (car x) (car y))))))
(setq result (delq nil
(mapcar
(lambda (x) (if (or (not match)
(string-match-p
match (car x)))
x))
result)))
(when (and (natnump count) (> count 0))
(setq result (nbutlast result (- (length result) count))))
result)))))))