Function: tar--extract
tar--extract is a byte-compiled function defined in tar-mode.el.gz.
Signature
(tar--extract DESCRIPTOR)
Documentation
Extract this entry of the tar file into its own buffer.
Source Code
;; Defined in /usr/src/emacs/lisp/tar-mode.el.gz
(defun tar--extract (descriptor)
"Extract this entry of the tar file into its own buffer."
(let* ((name (tar-header-name descriptor))
(size (tar-header-size descriptor))
(start (tar-header-data-start descriptor))
(end (+ start size))
(tarname (buffer-name))
(bufname (concat (file-name-nondirectory name)
" ("
tarname
")"))
(buffer (generate-new-buffer bufname)))
(with-current-buffer tar-data-buffer
(let (coding)
(narrow-to-region start end)
(goto-char start)
(setq coding (or coding-system-for-read
(and set-auto-coding-function
(funcall set-auto-coding-function
name (- end start)))
;; The following binding causes
;; find-buffer-file-type-coding-system
;; (defined on dos-w32.el) to act as if
;; the file being extracted existed, so
;; that the file's contents' encoding and
;; EOL format are auto-detected.
(let ((file-name-handler-alist
'(("" . tar-file-name-handler))))
(car (find-operation-coding-system
'insert-file-contents
(cons name (current-buffer)) t)))))
(if (or (not coding)
(eq (coding-system-type coding) 'undecided))
(setq coding (detect-coding-region start end t)))
(if (coding-system-get coding :for-unibyte)
(with-current-buffer buffer
(set-buffer-multibyte nil)))
(widen)
(with-current-buffer buffer
(setq buffer-undo-list t))
(decode-coding-region start end coding buffer)
(with-current-buffer buffer
(setq buffer-undo-list nil))))
buffer))