Function: dired--insert-disk-space

dired--insert-disk-space is a byte-compiled function defined in dired.el.gz.

Signature

(dired--insert-disk-space BEG FILE)

Source Code

;; Defined in /usr/src/emacs/lisp/dired.el.gz
(defun dired--insert-disk-space (beg file)
  ;; Try to insert the amount of free space.
  (save-excursion
    (goto-char beg)
    ;; First find the line to put it on.
    (if (not (re-search-forward "^ *\\(total\\)" nil t))
        beg
      (if (or (not dired-free-space)
              (eq dired-free-space 'first))
          (delete-region (match-beginning 0) (line-beginning-position 2))
        ;; Replace "total" with "total used in directory" to
        ;; avoid confusion.
        (replace-match "total used in directory" nil nil nil 1))
      (if-let ((available (get-free-disk-space file)))
        (cond
         ((eq dired-free-space 'separate)
	  (end-of-line)
	  (insert " available " available)
          ;; The separate free-space line is considered part of the
          ;; directory content, for the purposes of
          ;; 'dired-hide-details-mode'.
          (beginning-of-line)
          (point))
         ((eq dired-free-space 'first)
          (goto-char beg)
          (when (and (looking-at
                      (if (memq system-type '(windows-nt ms-dos))
                          " *[A-Za-z]:/"
                        " */"))
                     (progn
                       (end-of-line)
                       (eq (char-after (1- (point))) ?:)))
            (put-text-property (1- (point)) (point)
                               'display
                               (concat ": (" available " available)")))
          (forward-line 1)
          (point))
         (t
          beg))
        beg))))