Function: eshell-printable-size

eshell-printable-size is a byte-compiled function defined in esh-util.el.gz.

Signature

(eshell-printable-size FILESIZE &optional HUMAN-READABLE BLOCK-SIZE USE-COLORS)

Documentation

Return a printable FILESIZE.

Source Code

;; Defined in /usr/src/emacs/lisp/eshell/esh-util.el.gz
(defun eshell-printable-size (filesize &optional human-readable
				       block-size use-colors)
  "Return a printable FILESIZE."
  (when (and human-readable
             (not (= human-readable 1000))
             (not (= human-readable 1024)))
    (error "human-readable must be 1000 or 1024"))
  (let ((size (float (or filesize 0))))
    (if human-readable
        (let* ((flavor (and (= human-readable 1000) 'si))
               (str (file-size-human-readable size flavor)))
          (if (not use-colors)
              str
            (cond ((> size (expt human-readable 3))
                   (propertize str 'face 'bold-italic))
                  ((> size (expt human-readable 2))
                   (propertize str 'face 'bold))
                  (t str))))
      (if block-size
	  (setq size (/ size block-size)))
      (format "%.0f" size))))