Skip to content

Commit

Permalink
feat: add EXTRACT-OBJECT-AT-POS
Browse files Browse the repository at this point in the history
  • Loading branch information
fiddlerwoaroof committed Oct 26, 2023
1 parent 2733d76 commit 801495d
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions extract.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -79,16 +79,21 @@
(+ offset-offset
(* 4 obj-number))))

(defun extract-object-at-pos (pack pos ref)
(with-open-file (p (pack-file pack) :element-type '(unsigned-byte 8))
(file-position p pos)
(read-object-from-pack p
(repository pack)
ref)))

(defun extract-object-from-pack (pack obj-number ref)
(with-open-file (s (index-file pack) :element-type '(unsigned-byte 8))
(with-open-file (p (pack-file pack) :element-type '(unsigned-byte 8))
(file-position s (pack-offset-for-object (idx-toc s)
obj-number))
(let ((object-offset-in-pack (read-bytes 4 'fwoar.bin-parser:be->int s)))
(file-position p object-offset-in-pack)
(read-object-from-pack p
(repository pack)
ref)))))
(file-position s (pack-offset-for-object (idx-toc s)
obj-number))
(let ((object-offset-in-pack (read-bytes 4 'fwoar.bin-parser:be->int s)))
(extract-object-at-pos pack
object-offset-in-pack
ref))))

(defun extract-loose-object (repo file ref)
(with-open-file (s file :element-type '(unsigned-byte 8))
Expand Down

0 comments on commit 801495d

Please sign in to comment.