[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Resource file

On Jan 7, Clinton R Lefort asks:
 I have a resource file which I would like to load frm MCL, could someone give me
 an example, like (require-trap #_getresource or something..
For a complete example of using resources see the resources.lisp file in the
library directory (on the distribution). The code allows you to use resources
(attached to files) and to release them after use. 

Here are some of the macros and functions:
; Execute the BODY with REFNUM-VAR bound to the refnum for the resource
; file of FILE.  :IF-DOES-NOT-EXIST can be NIL, :ERROR, or :CREATE
(defmacro with-open-resource-file ((refnum-var file &key (if-does-not-exist 
                                   &body body)

; Open the resource FILE and return it's refnum.
; if-does-not-exist can be :error, nil or :create (just like OPEN).
; If ERRORP is NIL and there is an error, return two values: NIL and
; the error code.
(defun open-resource-file (file &key (if-does-not-exist :error) (errorp t))

; Close the resource file with the given refnum
(defun close-resource-file (refnum)

Consult the inside mac for the details on the various underlying traps calls.
The macros (and functions) in resources.lisp make it much easier to write code.