Function: tramp-do-directory-files-and-attributes-with-stat

tramp-do-directory-files-and-attributes-with-stat is a byte-compiled function defined in tramp-sh.el.gz.

Signature

(tramp-do-directory-files-and-attributes-with-stat VEC LOCALNAME &optional ID-FORMAT)

Documentation

Implement directory-files-and-attributes for Tramp files with stat(1) command.

Source Code

;; Defined in /usr/src/emacs/lisp/net/tramp-sh.el.gz
;; FIXME: Fix function to work with count parameter.
(defun tramp-do-directory-files-and-attributes-with-stat
  (vec localname &optional id-format)
  "Implement `directory-files-and-attributes' for Tramp files with stat(1) command."
  (tramp-message vec 5 "directory-files-and-attributes with stat: %s" localname)
  (tramp-send-command-and-read
   vec
   (format
    (concat
     ;; We must care about file names with spaces, or starting with
     ;; "-"; this would confuse xargs.  "ls -aQ" might be a solution,
     ;; but it does not work on all remote systems.  Therefore, we use
     ;; \000 as file separator.  `tramp-sh--quoting-style-options' do
     ;; not work for file names with spaces piped to "xargs".
     ;; Apostrophes in the stat output are masked as
     ;; `tramp-stat-marker', in order to make a proper shell escape of
     ;; them in file names.
     "cd %s && echo \"(\"; (%s %s -a | tr '\\n\\r' '\\000\\000' | "
     "xargs -0 %s -c "
     "'(%s%%n%s (%s%%N%s) %%h %s %s %%X %%Y %%Z %%s %s%%A%s t %%i -1)' "
     "-- 2>%s | sed -e 's/\"/\\\\\"/g' -e 's/%s/\"/g'); echo \")\"")
    (tramp-shell-quote-argument localname)
    (tramp-get-ls-command vec)
    ;; On systems which have no quoting style, file names with special
    ;; characters could fail.
    (tramp-sh--quoting-style-options vec)
    (tramp-get-remote-stat vec)
    tramp-stat-marker tramp-stat-marker
    tramp-stat-marker tramp-stat-marker
    (if (eq id-format 'integer)
	"%u"
      (eval-when-compile (concat tramp-stat-marker "%U" tramp-stat-marker)))
    (if (eq id-format 'integer)
	"%g"
      (eval-when-compile (concat tramp-stat-marker "%G" tramp-stat-marker)))
    tramp-stat-marker tramp-stat-marker
    (tramp-get-remote-null-device vec)
    tramp-stat-quoted-marker)))