home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!news.encore.com!csar!foxtail!sdd.hp.com!zaphod.mps.ohio-state.edu!saimiri.primate.wisc.edu!ames!data.nas.nasa.gov!taligent!apple!cambridge.apple.com!moon
- From: moon (David A. Moon)
- Newsgroups: comp.lang.lisp.mcl
- Subject: Re: Need help launching application in MCL (from a data file)
- Message-ID: <9211052145.AA28573@cambridge.apple.com>
- Date: 5 Nov 92 21:46:49 GMT
- Sender: info-mcl-request@cambridge.apple.com
- Lines: 53
- Approved: comp.lang.lisp.mcl@Cambridge.Apple.C0M
- Full-Name: David Moon
- Original-To: dmg@goldilocks.LCS.MIT.EDU (David Goodine)
- Original-Cc: info-mcl@cambridge.apple.com
-
- > Date: Thu, 5 Nov 92 16:27:14 EST
- > From: dmg@goldilocks.LCS.MIT.EDU (David Goodine)
- >
- > I'm trying to write some code that will take a pathname for an arbitrary
- > file and launch the application that created the file. I've managed to
- > launch an application explicitly, but can't figure out how to get the
- > mapping from the CREATOR of the file to the application (which the
- > finder seems to do internally).
- >
- > The inside-mac documentation here has been no help... it seems to happen
- > magically somewhere between the finder and the process manager...
-
- It is documented, but only for system 7. You want the PBDTGetAPPL trap. Try
- the following:
-
- ;;; -*- Mode: Lisp; Package: CCL -*-
-
- (in-package CCL)
-
- ;;; A handy subroutine, only works in system 7
- ;;; Returns the pathname of the application or nil if not found on any volume
- ;;; Several undocumented errors can occur, I hope I found them all
- (defun application-pathname (signature)
- (rlet ((pb :dtpbrec)
- (iopb :hparamblockrec))
- (%stack-block ((name 256))
- (setf (rref iopb :hparamblockrec.ioCompletion) (%null-ptr)
- (rref iopb :hparamblockrec.ioNamePtr) name)
- (loop for volume-index from 1 do
- (setf (rref iopb :hparamblockrec.ioVolIndex) volume-index
- (rref iopb :hparamblockrec.ioVRefNum) 0)
- (let ((err (#_PBHGetVInfo iopb)))
- (unless (zerop err)
- (if (= err #$nsvErr)
- (return-from application-pathname nil)
- (error "_PBHGetVInfo error #~D" err))))
- (setf (rref pb :dtpbrec.ioCompletion) (%null-ptr)
- (rref pb :dtpbrec.ioNamePtr) name
- (rref pb :dtpbrec.ioVRefNum)
- (rref iopb :hparamblockrec.ioVRefNum))
- (let ((err (#_PBDTGetPath pb)))
- (unless (zerop err)
- (unless (= err #$wrgVolTypErr)
- (error "_PBDTGetPath error #~D" err))))
- (setf (rref pb :dtpbrec.ioIndex) 0
- (rref pb :dtpbrec.ioFileCreator) signature)
- (let ((err (#_PBDTGetAPPL pb)))
- (cond ((zerop err)
- (setf (rref iopb :hparamblockrec.ioDirID)
- (rref pb :dtpbrec.ioAPPLParID))
- (return-from application-pathname (%path-from-iopb iopb)))
- ((and (/= err #$afpItemNotFound) (/= err #$fnfErr))
- (error "_PBDTGetAPPL error #~D" err))))))))
-