Function: tar-pad-to-blocksize
tar-pad-to-blocksize is a byte-compiled function defined in
tar-mode.el.gz.
Signature
(tar-pad-to-blocksize)
Documentation
If we are being anal about tar file blocksizes, fix up the current buffer.
Leaves the region wide.
Source Code
;; Defined in /usr/src/emacs/lisp/tar-mode.el.gz
;; When this function is called, it is sure that the buffer is unibyte.
(defun tar-pad-to-blocksize ()
"If we are being anal about tar file blocksizes, fix up the current buffer.
Leaves the region wide."
(if (null tar-anal-blocksize)
nil
(let* ((last-desc (nth (1- (length tar-parse-info)) tar-parse-info))
(start (tar-header-data-start last-desc))
(link-p (tar-header-link-type last-desc))
(size (if link-p 0 (tar-header-size last-desc)))
(data-end (+ start size))
(bbytes (ash tar-anal-blocksize 9))
(pad-to (+ bbytes (* bbytes (/ (- data-end (point-min)) bbytes)))))
;; If the padding after the last data is too long, delete some;
;; else insert some until we are padded out to the right number of blocks.
;;
(with-current-buffer tar-data-buffer
(let ((goal-end (+ (point-min) pad-to)))
(if (> (point-max) goal-end)
(delete-region goal-end (point-max))
(goto-char (point-max))
(insert (make-string (- goal-end (point-max)) ?\0))))))))