+/* START CODE SAMPLE FROM TECHNOTE 1002 (http://developer.apple.com/technotes/tn/tn1002.html) */
+
+ /* IsRemoteVolume can be used to find out if the
+ volume referred to by vRefNum is a remote volume
+ located somewhere on a network. the volume's attribute
+ flags (copied from the GetVolParmsInfoBuffer structure)
+ are returned in the longword pointed to by vMAttrib. */
+OSErr IsRemoteVolume(short vRefNum, Boolean *isRemote, long *vMAttrib) {
+ HParamBlockRec volPB;
+ GetVolParmsInfoBuffer volinfo;
+ OSErr err;
+ volPB.ioParam.ioVRefNum = vRefNum;
+ volPB.ioParam.ioNamePtr = NULL;
+ volPB.ioParam.ioBuffer = (Ptr) &volinfo;
+ volPB.ioParam.ioReqCount = sizeof(volinfo);
+ err = PBHGetVolParmsSync(&volPB);
+ if (err == noErr) {
+ *isRemote = (volinfo.vMServerAdr != 0);
+ *vMAttrib = volinfo.vMAttrib;
+ }
+ return err;
+}
+
+
+ /* BuildVolumeList fills the array pointed to by vols with
+ a list of the currently mounted volumes. If includeRemote
+ is true, then remote server volumes will be included in
+ the list. When remote server volumes are included in the
+ list, they will be added to the end of the list. On entry,
+ *count should contain the size of the array pointed to by
+ vols. On exit, *count will be set to the number of id numbers
+ placed in the array. If vMAttribMask is non-zero, then
+ only volumes with matching attributes are added to the
+ list of volumes. bits in the vMAttribMask should use the
+ same encoding as bits in the vMAttrib field of
+ the GetVolParmsInfoBuffer structure. */
+OSErr BuildVolumeList(Boolean includeRemote, short *vols,
+ long *count, long vMAttribMask) {
+ HParamBlockRec volPB;
+ Boolean isRemote;
+ OSErr err;
+ long nlocal, nremote;
+ long vMAttrib;
+
+ /* set up and check parameters */
+ volPB.volumeParam.ioNamePtr = NULL;
+ nlocal = nremote = 0;
+ if (*count == 0) return noErr;
+
+ /* iterate through volumes */
+ for (volPB.volumeParam.ioVolIndex = 1;
+ PBHGetVInfoSync(&volPB) == noErr;
+ volPB.volumeParam.ioVolIndex++) {
+
+ /* skip remote volumes, if necessary */
+ err = IsRemoteVolume(volPB.volumeParam.ioVRefNum, &isRemote, &vMAttrib);
+ if (err != noErr) goto bail;
+ if ( ( includeRemote || ! isRemote )
+ && (vMAttrib & vMAttribMask) == vMAttribMask ) {
+
+ /* add local volumes at the front, remote
+ volumes at the end */
+ if (isRemote)
+ vols[nlocal + nremote++] = volPB.volumeParam.ioVRefNum;
+ else {
+ if (nremote > 0)
+ BlockMoveData(vols+nlocal, vols+nlocal+1,
+ nremote*sizeof(short));
+ vols[nlocal++] = volPB.volumeParam.ioVRefNum;
+ }
+
+ /* list full? */
+ if ((nlocal + nremote) >= *count) break;
+ }
+ }
+bail:
+ *count = (nlocal + nremote);
+ return err;
+}
+
+
+ /* FindApplication iterates through mounted volumes
+ searching for an application with the given creator
+ type. If includeRemote is true, then remote volumes
+ will be searched (after local ones) for an application
+ with the creator type. */
+
+#define kMaxVols 20
+
+/* Hacked to output to appName */
+
+OSErr FindApplication(OSType appCreator, Boolean includeRemote, Str255 appName) {
+ short rRefNums[kMaxVols];
+ long i, volCount;
+ DTPBRec desktopPB;
+ OSErr err;
+ FSSpec realappSpec;
+ FSSpec *appSpec = &realappSpec;
+
+ /* get a list of volumes - with desktop files */
+ volCount = kMaxVols;
+ err = BuildVolumeList(includeRemote, rRefNums, &volCount,
+ (1<<bHasDesktopMgr) );
+ if (err != noErr) return err;
+
+ /* iterate through the list */
+ for (i=0; i<volCount; i++) {
+
+ /* has a desktop file? */
+ desktopPB.ioCompletion = NULL;
+ desktopPB.ioVRefNum = rRefNums[i];
+ desktopPB.ioNamePtr = NULL;
+ desktopPB.ioIndex = 0;
+ err = PBDTGetPath(&desktopPB);
+ if (err != noErr) continue;
+
+ /* has the correct app?? */
+ desktopPB.ioFileCreator = appCreator;
+ desktopPB.ioNamePtr = appName;
+ err = PBDTGetAPPLSync(&desktopPB);
+ if (err != noErr) continue;
+
+ /* make a file spec referring to it */
+ err = FSMakeFSSpec(rRefNums[i],
+ desktopPB.ioAPPLParID, appName,
+ appSpec);
+ if (err != noErr) continue;
+
+ /* found it! */
+ return noErr;
+
+ }
+ return fnfErr;
+}
+
+/* END CODE SAMPLE FROM TECHNOTE 1002 (http://developer.apple.com/technotes/tn/tn1002.html) */
+
+wxString wxFileTypeImpl::GetCommand(const wxString& verb) const