Browse code
feat: add EXTRACT-OBJECT-AT-POS
Edward Langley authored on 26/10/2023 00:56:23
Showing 1 changed files
Showing 1 changed files
... | ... |
@@ -79,16 +79,21 @@ |
79 | 79 |
(+ offset-offset |
80 | 80 |
(* 4 obj-number)))) |
81 | 81 |
|
82 |
+(defun extract-object-at-pos (pack pos ref) |
|
83 |
+ (with-open-file (p (pack-file pack) :element-type '(unsigned-byte 8)) |
|
84 |
+ (file-position p pos) |
|
85 |
+ (read-object-from-pack p |
|
86 |
+ (repository pack) |
|
87 |
+ ref))) |
|
88 |
+ |
|
82 | 89 |
(defun extract-object-from-pack (pack obj-number ref) |
83 | 90 |
(with-open-file (s (index-file pack) :element-type '(unsigned-byte 8)) |
84 |
- (with-open-file (p (pack-file pack) :element-type '(unsigned-byte 8)) |
|
85 |
- (file-position s (pack-offset-for-object (idx-toc s) |
|
86 |
- obj-number)) |
|
87 |
- (let ((object-offset-in-pack (read-bytes 4 'fwoar.bin-parser:be->int s))) |
|
88 |
- (file-position p object-offset-in-pack) |
|
89 |
- (read-object-from-pack p |
|
90 |
- (repository pack) |
|
91 |
- ref))))) |
|
91 |
+ (file-position s (pack-offset-for-object (idx-toc s) |
|
92 |
+ obj-number)) |
|
93 |
+ (let ((object-offset-in-pack (read-bytes 4 'fwoar.bin-parser:be->int s))) |
|
94 |
+ (extract-object-at-pos pack |
|
95 |
+ object-offset-in-pack |
|
96 |
+ ref)))) |
|
92 | 97 |
|
93 | 98 |
(defun extract-loose-object (repo file ref) |
94 | 99 |
(with-open-file (s file :element-type '(unsigned-byte 8)) |