Function: tar-summarize-buffer

tar-summarize-buffer is a byte-compiled function defined in tar-mode.el.gz.

Signature

(tar-summarize-buffer)

Documentation

Parse the contents of the tar file in the current buffer.

Source Code

;; Defined in /usr/src/emacs/lisp/tar-mode.el.gz
(defun tar-summarize-buffer ()
  "Parse the contents of the tar file in the current buffer."
  (cl-assert (tar-data-swapped-p))
  (let* ((modified (buffer-modified-p))
         (result '())
         (pos (point-min))
	 (coding tar-file-name-coding-system)
         (progress-reporter
          (with-current-buffer tar-data-buffer
            (make-progress-reporter "Parsing tar file..."
                                    (point-min) (point-max))))
         descriptor)
    (with-current-buffer tar-data-buffer
      (while (and (< pos (point-max))
                  (setq descriptor (tar-header-block-tokenize pos coding)))
        (let ((size (tar-header-size descriptor)))
          (if (< size 0)
              (error "%s has size %s - corrupted"
                     (tar-header-name descriptor) size)))
        ;;
        ;; This is just too slow.  Don't really need it anyway....
        ;;(tar-header-block-check-checksum
        ;;  hblock (tar-header-block-checksum hblock)
        ;;  (tar-header-name descriptor))

        (push descriptor result)
        (setq pos (tar-header-data-end descriptor))
        (progress-reporter-update progress-reporter pos)))

    (setq-local tar-parse-info (nreverse result))
    ;; A tar file should end with a block or two of nulls,
    ;; but let's not get a fatal error if it doesn't.
    (if (null descriptor)
        (progress-reporter-done progress-reporter)
      (message "Warning: premature EOF parsing tar file"))
    (goto-char (point-min))
    (let ((create-lockfiles nil) ; avoid changing dir mtime by lock_file
	  (inhibit-read-only t)
          (total-summaries
           (mapconcat #'tar-header-block-summarize tar-parse-info "\n")))
      (insert total-summaries "\n")
      (goto-char (point-min))
      (restore-buffer-modified-p modified))))