Commit 925746c4 authored by Eric Timmons's avatar Eric Timmons
Browse files

Remove ENTRY-BUFFER slot

parent 3e003885
......@@ -17,12 +17,7 @@
*default-archive-type*))
(defclass archive ()
((entry-buffer
:initarg :entry-buffer
:initform (make-array +tar-n-block-bytes+ :element-type '(unsigned-byte 8))
:reader entry-buffer
:type (simple-array (unsigned-byte 8) (#.+tar-n-block-bytes+)))
(direction
((direction
:initarg :direction
:reader %archive-direction)
(open-archive-p
......@@ -72,13 +67,6 @@ Further operations on the archive are undefined."
(setf (open-archive-p archive) nil))
t)
(defun read-entry-block (archive)
(with-slots (entry-buffer stream) archive
(let ((nbytes (read-sequence entry-buffer stream)))
(unless (= nbytes (length entry-buffer))
(error "Corrupt archive"))
entry-buffer)))
(defun read-data-block (archive block-length &optional (pad-func #'identity))
"Read a (SIMPLE-ARRAY (UNSIGNED-BYTE 8) (*)) array of BLOCK-LENGTH
from ARCHIVE. BLOCK-LENGTH is padded with PAD-FUNC to meet archive
......@@ -119,10 +107,12 @@ requirements about alignment."
(defmethod write-entry-to-archive ((archive archive) entry
&key (stream t))
(with-slots (entry-buffer (archive-stream stream)) archive
;; write the entry
(write-header-to-buffer entry entry-buffer 0)
(write-sequence entry-buffer archive-stream)
(with-slots ((archive-stream stream)) archive
(let ((buffer (make-array +tar-n-block-bytes+ :element-type '(unsigned-byte 8))))
(declare (dynamic-extent buffer))
;; write the entry
(write-header-to-buffer entry buffer 0)
(write-sequence buffer archive-stream))
;; write any associated data
(write-entry-data archive entry stream)
(values)))
......@@ -138,10 +128,15 @@ requirements about alignment."
(defmethod read-entry-from-archive ((archive archive))
(let ((start-position (file-position (archive-stream archive)))
(entry-block (read-entry-block archive)))
(if (null-block-p entry-block 0)
(buffer (make-array +tar-n-block-bytes+ :element-type '(unsigned-byte 8))))
(declare (dynamic-extent buffer))
(with-slots (stream) archive
(let ((nbytes (read-sequence buffer stream)))
(unless (= nbytes +tar-n-block-bytes+)
(error "Corrupt archive"))))
(if (null-block-p buffer 0)
nil
(let ((header (read-header-from-buffer (archive-header-type archive) entry-block :start 0)))
(let ((header (read-header-from-buffer (archive-header-type archive) buffer :start 0)))
(make-instance (archive-entry-type archive header)
:archive archive
:header header
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment