Function: eshell-du-sum-directory
eshell-du-sum-directory is a byte-compiled function defined in
em-unix.el.gz.
Signature
(eshell-du-sum-directory PATH DEPTH-REMAINING &rest ARGS &key PRINT-FUNCTION SHOW-ALL DEREFERENCE-LINKS ONLY-ONE-FILESYSTEM SEEN-FILES)
Documentation
Summarize PATH, and its member directories.
Source Code
;; Defined in /usr/src/emacs/lisp/eshell/em-unix.el.gz
(cl-defun eshell-du-sum-directory (path depth-remaining &rest args
&key print-function show-all
dereference-links only-one-filesystem
seen-files)
"Summarize PATH, and its member directories."
(let ((size 0.0))
(dolist (entry (eshell-directory-files-and-attributes path))
(unless (or (string-match "\\`\\.\\.?\\'" (car entry))
(gethash (file-attribute-file-identifier (cdr entry))
seen-files))
(puthash (file-attribute-file-identifier (cdr entry)) t seen-files)
(let* ((file-name (concat path "/" (car entry)))
(file-type (file-attribute-type (cdr entry)))
(symlink (and (stringp file-type) file-type)))
(unless (or (and symlink (not dereference-links))
(and only-one-filesystem
(/= only-one-filesystem
(file-attribute-device-number (cdr entry)))))
(when symlink
(setq file-name symlink))
(setq size
(+ size
(if (eq file-type t) ; This is a directory.
(apply #'eshell-du-sum-directory file-name
(when depth-remaining (1- depth-remaining))
args)
(let ((file-size (file-attribute-size (cdr entry))))
(when show-all
(funcall print-function file-size file-name))
file-size))))))))
(when (or (not depth-remaining)
(natnump depth-remaining))
(funcall print-function size (directory-file-name path)))
size))