Mercurial > cpython-lru_cache-weakref
annotate Mac/Python/getapplbycreator.c @ 25838:8540887bcec6 2.2
Backport of 2.183:
Fix memory leak in add_subclass() found by NealN with valgrind.
| author | Guido van Rossum <guido@python.org> |
|---|---|
| date | Fri, 18 Oct 2002 13:42:21 +0000 |
| parents | ccb6d76633be |
| children |
| rev | line source |
|---|---|
|
5079
d6b292a33cfe
Added/updated copyright notices
Jack Jansen <jack.jansen@cwi.nl>
parents:
4319
diff
changeset
|
1 /*********************************************************** |
|
d6b292a33cfe
Added/updated copyright notices
Jack Jansen <jack.jansen@cwi.nl>
parents:
4319
diff
changeset
|
2 Copyright 1991-1997 by Stichting Mathematisch Centrum, Amsterdam, |
|
d6b292a33cfe
Added/updated copyright notices
Jack Jansen <jack.jansen@cwi.nl>
parents:
4319
diff
changeset
|
3 The Netherlands. |
|
d6b292a33cfe
Added/updated copyright notices
Jack Jansen <jack.jansen@cwi.nl>
parents:
4319
diff
changeset
|
4 |
|
d6b292a33cfe
Added/updated copyright notices
Jack Jansen <jack.jansen@cwi.nl>
parents:
4319
diff
changeset
|
5 All Rights Reserved |
|
d6b292a33cfe
Added/updated copyright notices
Jack Jansen <jack.jansen@cwi.nl>
parents:
4319
diff
changeset
|
6 |
|
d6b292a33cfe
Added/updated copyright notices
Jack Jansen <jack.jansen@cwi.nl>
parents:
4319
diff
changeset
|
7 Permission to use, copy, modify, and distribute this software and its |
|
d6b292a33cfe
Added/updated copyright notices
Jack Jansen <jack.jansen@cwi.nl>
parents:
4319
diff
changeset
|
8 documentation for any purpose and without fee is hereby granted, |
|
d6b292a33cfe
Added/updated copyright notices
Jack Jansen <jack.jansen@cwi.nl>
parents:
4319
diff
changeset
|
9 provided that the above copyright notice appear in all copies and that |
|
d6b292a33cfe
Added/updated copyright notices
Jack Jansen <jack.jansen@cwi.nl>
parents:
4319
diff
changeset
|
10 both that copyright notice and this permission notice appear in |
|
d6b292a33cfe
Added/updated copyright notices
Jack Jansen <jack.jansen@cwi.nl>
parents:
4319
diff
changeset
|
11 supporting documentation, and that the names of Stichting Mathematisch |
|
d6b292a33cfe
Added/updated copyright notices
Jack Jansen <jack.jansen@cwi.nl>
parents:
4319
diff
changeset
|
12 Centrum or CWI or Corporation for National Research Initiatives or |
|
d6b292a33cfe
Added/updated copyright notices
Jack Jansen <jack.jansen@cwi.nl>
parents:
4319
diff
changeset
|
13 CNRI not be used in advertising or publicity pertaining to |
|
d6b292a33cfe
Added/updated copyright notices
Jack Jansen <jack.jansen@cwi.nl>
parents:
4319
diff
changeset
|
14 distribution of the software without specific, written prior |
|
d6b292a33cfe
Added/updated copyright notices
Jack Jansen <jack.jansen@cwi.nl>
parents:
4319
diff
changeset
|
15 permission. |
|
d6b292a33cfe
Added/updated copyright notices
Jack Jansen <jack.jansen@cwi.nl>
parents:
4319
diff
changeset
|
16 |
|
d6b292a33cfe
Added/updated copyright notices
Jack Jansen <jack.jansen@cwi.nl>
parents:
4319
diff
changeset
|
17 While CWI is the initial source for this software, a modified version |
|
d6b292a33cfe
Added/updated copyright notices
Jack Jansen <jack.jansen@cwi.nl>
parents:
4319
diff
changeset
|
18 is made available by the Corporation for National Research Initiatives |
|
d6b292a33cfe
Added/updated copyright notices
Jack Jansen <jack.jansen@cwi.nl>
parents:
4319
diff
changeset
|
19 (CNRI) at the Internet address ftp://ftp.python.org. |
|
d6b292a33cfe
Added/updated copyright notices
Jack Jansen <jack.jansen@cwi.nl>
parents:
4319
diff
changeset
|
20 |
|
d6b292a33cfe
Added/updated copyright notices
Jack Jansen <jack.jansen@cwi.nl>
parents:
4319
diff
changeset
|
21 STICHTING MATHEMATISCH CENTRUM AND CNRI DISCLAIM ALL WARRANTIES WITH |
|
d6b292a33cfe
Added/updated copyright notices
Jack Jansen <jack.jansen@cwi.nl>
parents:
4319
diff
changeset
|
22 REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF |
|
d6b292a33cfe
Added/updated copyright notices
Jack Jansen <jack.jansen@cwi.nl>
parents:
4319
diff
changeset
|
23 MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH |
|
d6b292a33cfe
Added/updated copyright notices
Jack Jansen <jack.jansen@cwi.nl>
parents:
4319
diff
changeset
|
24 CENTRUM OR CNRI BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL |
|
d6b292a33cfe
Added/updated copyright notices
Jack Jansen <jack.jansen@cwi.nl>
parents:
4319
diff
changeset
|
25 DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR |
|
d6b292a33cfe
Added/updated copyright notices
Jack Jansen <jack.jansen@cwi.nl>
parents:
4319
diff
changeset
|
26 PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER |
|
d6b292a33cfe
Added/updated copyright notices
Jack Jansen <jack.jansen@cwi.nl>
parents:
4319
diff
changeset
|
27 TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR |
|
d6b292a33cfe
Added/updated copyright notices
Jack Jansen <jack.jansen@cwi.nl>
parents:
4319
diff
changeset
|
28 PERFORMANCE OF THIS SOFTWARE. |
|
d6b292a33cfe
Added/updated copyright notices
Jack Jansen <jack.jansen@cwi.nl>
parents:
4319
diff
changeset
|
29 |
|
d6b292a33cfe
Added/updated copyright notices
Jack Jansen <jack.jansen@cwi.nl>
parents:
4319
diff
changeset
|
30 ******************************************************************/ |
|
d6b292a33cfe
Added/updated copyright notices
Jack Jansen <jack.jansen@cwi.nl>
parents:
4319
diff
changeset
|
31 |
|
4319
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
32 /* |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
33 ** FindApplicationFromCreator uses the Desktop Database to |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
34 ** locate the creator application for the given document |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
35 ** |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
36 ** this routine will check the desktop database of all local |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
37 ** disks, then the desktop databases of all server volumes |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
38 ** (so up to two passes will be made) |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
39 ** |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
40 ** This code was created from FindApplicationFromDocument |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
41 ** routine, origin unknown. |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
42 */ |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
43 |
|
17867
ccb6d76633be
Another include Carbon/Carbon.h
Jack Jansen <jack.jansen@cwi.nl>
parents:
5079
diff
changeset
|
44 #ifdef WITHOUT_FRAMEWORKS |
|
4319
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
45 #include <Types.h> |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
46 #include <Files.h> |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
47 #include <Errors.h> |
|
17867
ccb6d76633be
Another include Carbon/Carbon.h
Jack Jansen <jack.jansen@cwi.nl>
parents:
5079
diff
changeset
|
48 #else |
|
ccb6d76633be
Another include Carbon/Carbon.h
Jack Jansen <jack.jansen@cwi.nl>
parents:
5079
diff
changeset
|
49 #include <Carbon/Carbon.h> |
|
ccb6d76633be
Another include Carbon/Carbon.h
Jack Jansen <jack.jansen@cwi.nl>
parents:
5079
diff
changeset
|
50 #endif |
|
4319
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
51 #include "getapplbycreator.h" |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
52 |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
53 |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
54 OSErr FindApplicationFromCreator(OSType creator, |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
55 FSSpecPtr applicationFSSpecPtr) |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
56 { |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
57 enum { localPass, remotePass, donePass } volumePass; |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
58 DTPBRec desktopParams; |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
59 HParamBlockRec hfsParams; |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
60 short volumeIndex; |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
61 Boolean foundFlag; |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
62 GetVolParmsInfoBuffer volumeInfoBuffer; |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
63 OSErr retCode; |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
64 |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
65 /* dkj 12/94 initialize flag to false (thanks to Peter Baral for pointing out this bug) */ |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
66 foundFlag = false; |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
67 |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
68 volumePass = localPass; |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
69 volumeIndex = 0; |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
70 |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
71 do { |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
72 /* |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
73 ** first, find the vRefNum of the volume whose Desktop Database |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
74 ** we're checking this time |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
75 */ |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
76 |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
77 volumeIndex++; |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
78 |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
79 /* convert the volumeIndex into a vRefNum */ |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
80 |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
81 hfsParams.volumeParam.ioNamePtr = nil; |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
82 hfsParams.volumeParam.ioVRefNum = 0; |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
83 hfsParams.volumeParam.ioVolIndex = volumeIndex; |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
84 retCode = PBHGetVInfoSync(&hfsParams); |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
85 |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
86 /* a nsvErr indicates that the current pass is over */ |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
87 if (retCode == nsvErr) goto SkipThisVolume; |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
88 if (retCode != noErr) goto Bail; |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
89 |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
90 /* |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
91 ** call GetVolParms to determine if this volume is a server |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
92 ** (a remote volume) |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
93 */ |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
94 |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
95 hfsParams.ioParam.ioBuffer = (Ptr) &volumeInfoBuffer; |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
96 hfsParams.ioParam.ioReqCount = sizeof(GetVolParmsInfoBuffer); |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
97 retCode = PBHGetVolParmsSync(&hfsParams); |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
98 if (retCode != noErr) goto Bail; |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
99 |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
100 /* |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
101 ** if the vMServerAdr field of the volume information buffer |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
102 ** is zero, this is a local volume; skip this volume |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
103 ** if it's local on a remote pass or remote on a local pass |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
104 */ |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
105 |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
106 if ((volumeInfoBuffer.vMServerAdr != 0) != |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
107 (volumePass == remotePass)) goto SkipThisVolume; |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
108 |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
109 /* okay, now we've found the vRefNum for our desktop database call */ |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
110 |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
111 desktopParams.ioVRefNum = hfsParams.volumeParam.ioVRefNum; |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
112 |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
113 /* |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
114 ** find the path refNum for the desktop database for |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
115 ** the volume we're interested in |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
116 */ |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
117 |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
118 desktopParams.ioNamePtr = nil; |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
119 |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
120 retCode = PBDTGetPath(&desktopParams); |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
121 if (retCode == noErr && desktopParams.ioDTRefNum != 0) { |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
122 |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
123 /* |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
124 ** use the GetAPPL call to find the preferred application |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
125 ** for opening any document with this one's creator |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
126 */ |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
127 |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
128 desktopParams.ioIndex = 0; |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
129 desktopParams.ioFileCreator = creator; |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
130 desktopParams.ioNamePtr = applicationFSSpecPtr->name; |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
131 retCode = PBDTGetAPPLSync(&desktopParams); |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
132 |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
133 if (retCode == noErr) { |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
134 /* |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
135 ** okay, found it; fill in the application file spec |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
136 ** and set the flag indicating we're done |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
137 */ |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
138 |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
139 applicationFSSpecPtr->parID = desktopParams.ioAPPLParID; |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
140 applicationFSSpecPtr->vRefNum = desktopParams.ioVRefNum; |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
141 foundFlag = true; |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
142 |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
143 } |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
144 } |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
145 |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
146 SkipThisVolume: |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
147 /* |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
148 ** if retCode indicates a no such volume error or if this |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
149 ** was the first pass, it's time to move on to the next pass |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
150 */ |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
151 |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
152 if (retCode == nsvErr) { |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
153 volumePass++; |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
154 volumeIndex = 0; |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
155 } |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
156 |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
157 } while (foundFlag == false && volumePass != donePass); |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
158 |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
159 Bail: |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
160 if (retCode == nsvErr) |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
161 return fnfErr; /* More logical than "No such volume" */ |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
162 return retCode; |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
163 } |
