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)

Documentation

Summarize PATH, and its member directories.

Source Code

;; Defined in /usr/src/emacs/lisp/eshell/em-unix.el.gz
(defun eshell-du-sum-directory (path depth)
  "Summarize PATH, and its member directories."
  (let ((entries (eshell-directory-files-and-attributes path))
	(size 0.0))
    (while entries
      (unless (string-match "\\`\\.\\.?\\'" (caar entries))
	(let* ((entry (concat path "/"
			      (caar entries)))
	       (symlink (and (stringp (file-attribute-type (cdar entries)))
			     (file-attribute-type (cdar entries)))))
	  (unless (or (and symlink (not dereference-links))
		      (and only-one-filesystem
			   (/= only-one-filesystem
			       (file-attribute-device-number (cdar entries)))))
	    (if symlink
		(setq entry symlink))
	    (setq size
		  (+ size
		     (if (eq t (car (cdar entries)))
			 (eshell-du-sum-directory entry (1+ depth))
		       (let ((file-size (file-attribute-size (cdar entries))))
			 (prog1
			     file-size
			   (if show-all
			       (eshell-print
				(concat (eshell-du-size-string file-size)
					entry "\n")))))))))))
      (setq entries (cdr entries)))
    (if (or (not max-depth)
	    (= depth max-depth)
	    (= depth 0))
	(eshell-print (concat (eshell-du-size-string size)
			      (directory-file-name path) "\n")))
    size))