-
Notifications
You must be signed in to change notification settings - Fork 0
/
archive.lisp
27 lines (23 loc) · 1.03 KB
/
archive.lisp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
(in-package #:qldeb)
;;;; Archive-related helpers
(defmacro loop-entries (vars &body body)
(let ((unhandled-error (gensym))
(continue (gensym)))
`(loop for ,(first vars) = (handler-case
(archive:read-entry-from-archive ,(second vars))
(archive:unhandled-read-header-error ()
',unhandled-error))
until (null ,(first vars))
do (block ,continue
(when (eq ,(first vars) ',unhandled-error)
(return-from ,continue))
(progn ,@body)
(archive:discard-entry ,(second vars) ,(first vars))))))
(defun archive-entry (archive path)
(loop-entries (entry archive)
(when (pathname-match-p path (pathname
(flexi-streams:octets-to-string
(archive::%name entry))))
(return-from archive-entry entry))))
(defun read-entry (entry)
(flexi-streams:make-flexi-stream (archive:entry-stream entry)))