Function: tar-alter-one-field
tar-alter-one-field is a byte-compiled function defined in
tar-mode.el.gz.
Signature
(tar-alter-one-field DATA-POSITION NEW-DATA-STRING &optional DESCRIPTOR)
Source Code
;; Defined in /usr/src/emacs/lisp/tar-mode.el.gz
(defun tar-alter-one-field (data-position new-data-string &optional descriptor)
(unless descriptor (setq descriptor (tar-current-descriptor)))
;;
;; update the header-line.
(let ((col (current-column)))
(delete-region (line-beginning-position)
(prog2 (forward-line 1)
(point)
;; Insert the new text after the old, before deleting,
;; to preserve markers such as the window start.
(insert (tar-header-block-summarize descriptor) "\n")))
(forward-line -1) (move-to-column col))
(cl-assert (tar-data-swapped-p))
(with-current-buffer tar-data-buffer
(let* ((start (- (tar-header-data-start descriptor) 512)))
;;
;; delete the old field and insert a new one.
(goto-char (+ start data-position))
(delete-region (point) (+ (point) (length new-data-string))) ; <--
(cl-assert (not (or enable-multibyte-characters
(multibyte-string-p new-data-string))))
(insert new-data-string)
;;
;; compute a new checksum and insert it.
(let ((chk (tar-header-block-checksum
(buffer-substring start (+ start 512)))))
(goto-char (+ start tar-chk-offset))
(delete-region (point) (+ (point) 8))
(insert (format "%6o\0 " chk))
(setf (tar-header-checksum descriptor) chk)
;;
;; ok, make sure we didn't botch it.
(tar-header-block-check-checksum
(buffer-substring start (+ start 512))
chk (tar-header-name descriptor))
))))