[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Need help launching application in MCL (from a data file)
- To: dmg@goldilocks.LCS.MIT.EDU (David Goodine)
- Subject: Re: Need help launching application in MCL (from a data file)
- From: moon (David A. Moon)
- Date: Thu, 05 Nov 92 16:46:49 EST
- 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))))))))