changeset 43777:c62ae85e0f7b

(tar-untar-buffer): New function.
author Richard M. Stallman <rms@gnu.org>
date Fri, 08 Mar 2002 09:54:42 +0000
parents 5de6df44f85f
children 21f583da1eac
files lisp/tar-mode.el
diffstat 1 files changed, 21 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/tar-mode.el	Fri Mar 08 09:39:16 2002 +0000
+++ b/lisp/tar-mode.el	Fri Mar 08 09:54:42 2002 +0000
@@ -373,6 +373,27 @@
 		(concat (if (= type 1) " ==> " " --> ") link-name)
 	      ""))))
 
+(defun tar-untar-buffer ()
+  "Extract all archive members in the tar-file."
+  (interactive)
+  (let ((multibyte enable-multibyte-characters))
+    (unwind-protect
+	(save-restriction
+	  (widen)
+	  (set-buffer-multibyte nil)
+	  (dolist (descriptor tar-parse-info)
+	    (let* ((tokens (tar-desc-tokens descriptor))
+		   (name (tar-header-name tokens))
+		   (dir (file-name-directory name))
+		   (start (+ (tar-desc-data-start descriptor) tar-header-offset -1))
+		   (end (+ start (tar-header-size tokens))))
+	      (message "Extracting %s" name)
+	      (if (and dir (not (file-exists-p dir)))
+		  (make-directory dir t))
+	      (write-region start end name)
+	      (set-file-modes name (tar-header-mode tokens)))))
+      (set-buffer-multibyte multibyte))))
+
 (defun tar-summarize-buffer ()
   "Parse the contents of the tar file in the current buffer.
 Place a dired-like listing on the front;