-
Notifications
You must be signed in to change notification settings - Fork 0
/
file.lisp
50 lines (31 loc) · 1.27 KB
/
file.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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
;;;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; Base: 10 -*
(in-package #:alcove)
(defun add-root-ohdr (input-stream file)
(nconc file `((root-ohdr . ,(read-ohdr input-stream
(get-root-ohdr-address file)
file)))))
(defun add-superblock (input-stream file)
(nconc file `((superblock . ,(read-superblock input-stream)))))
(defun get-base-adress (file)
(cdr (assoc 'base-address (get-superblock file))))
(defun get-file-name (file)
(cdr (assoc 'file-name file)))
(defun get-size-of-lengths (file)
(cdr (assoc 'size-of-lengths (get-superblock file))))
(defun get-size-of-offsets (file)
(cdr (assoc 'size-of-offsets (get-superblock file))))
(defun get-root-ohdr-address (file)
(let* ((sblk (get-superblock file))
(version (cdr (assoc 'sblk-version sblk))))
(cond
((or (= version 0) (= version 1))
(+ (cdr (assoc 'base-address sblk))
(cdr (assoc 'ohdr-address (cdr (assoc 'root-stbl-entry sblk))))))
((= version 2)
(+ (cdr (assoc 'base-address sblk))
(cdr (assoc 'root-ohdr-address sblk))))
(t nil))))
(defun get-superblock (file)
(cdr (assoc 'superblock file)))
(defun make-file (file-name)
`((file-name . ,file-name)))