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

Re: duplicate-resource

wilcox@cmns.think.com writes:
 The file resources.lisp is a great improvement over the resource tools
 provided in MACL 1.3 (i.e. none). However, it does not do one thing I
 need (which I think is fairly basic): duplicate a resource from one file
 to another. According to Inside Macintosh I-124, this involves the traps
 _AddResource, _DetachResource and _HandToHand. (Unfortunately, they do not
 include a LISP example!) My attempt at writing a function for this resulted
 merely in the Mac Bomb Box. Any suggestions or code would be appreciated.

The library:resources.lisp contains high level interfaces to add-resource
detach-resource that make the traps calls much easier. You'll still need
to copy the resource handle and presumably create a new resource id
unless you want to use the same resource id.

If you want to copy a handle, you'll need to include the following
code for copying handles (courtesy of Bill St. Clair):

(in-package ccl)
(export '(copy-handle))
;; wrapper for handToHand trap call
(defun copy-handle (handle)
  "returns a handle whose contents is a copy of the input handle's contents"
  (rlet ((var :ptr))
    (ccl::%set-ptr var handle)
    (let ((errcode (#_HandToHand var)))
      (unless (eql 0 errcode)
        (ccl::%err-disp errcode))
      (%get-ptr var))))