Ignore:
Timestamp:
10/20/02 04:46:29 (20 years ago)
Author:
Nicholas Riley
Message:

F-Script Anywhere 1.1.5

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Cocoa/F-Script Anywhere/Source/DeVercruesseProcess.m

    r7 r16  
    2020//  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
    2121//  02111-1307, USA.
    22 
    23 // njr changes:
    2422
    2523#import "DeVercruesseProcess.h"
     
    102100- (NSString *)executableLoc;
    103101{
    104     CFURLRef bundleURL = CFURLCreateWithFileSystemPath(NULL, (CFStringRef) [self loc], kCFURLPOSIXPathStyle, NO);
    105     CFBundleRef bundleRef = CFBundleCreate(NULL, bundleURL);
     102    CFStringRef bundleLoc = (CFStringRef) [self loc];
     103    CFURLRef bundleURL;
     104    CFBundleRef bundleRef;
     105
     106    if (bundleLoc == NULL) {
     107        // GetProcessBundleLocation returns NULL on 10.1.5 for certain CFM Carbon applications (BBEdit 6.5.3) - njr
     108        return nil; // XXX should really handle this better, but for the purposes of F-Script Anywhere, we donÕt care if itÕs not a Carbon app, and this works fine going forward.
     109    }
     110   
     111    bundleURL = CFURLCreateWithFileSystemPath(NULL, bundleLoc, kCFURLPOSIXPathStyle, NO);
     112    bundleRef = CFBundleCreate(NULL, bundleURL);
    106113
    107114    if (bundleRef == NULL) {
     115        BOOL isDir;
    108116        CFRelease(bundleURL);
    109         return nil; // not a bundle
     117        if ([[NSFileManager defaultManager] fileExistsAtPath: [self loc] isDirectory: &isDir] && !isDir)
     118            return [self loc];
     119        return nil; // not a bundle or file
    110120    } else {
    111121        CFURLRef execURL = CFBundleCopyExecutableURL(bundleRef);
     
    144154    char                buffer[1025];
    145155    CFStringRef         pName;
    146     NSBundle            *b;
    147156   
    148157   
    149158    if( !name )
    150159    {
    151         if( [self loc] )
    152         {
    153             b = [NSBundle bundleWithPath:loc];
    154             if( b )
    155             {
    156                 name = [b localizedStringForKey:@"CFBundleName" value:@"_AsM_nO_nAmE_" table:@"InfoPlist"];
    157                
    158                 if( [name isEqualToString:@"_AsM_nO_nAmE_"] )
    159                     name = [[b infoDictionary] objectForKey:@"CFBundleName"];
    160                
    161                 if( name )
    162                     [name retain];
    163             }
    164         }
    165        
    166160        if( !name && (CopyProcessName( &psn, &pName) == noErr) )    // with thanks to Dylan Ashe
    167161        {
     
    173167            CFRelease( pName);
    174168        }
    175     }
    176    
    177     return name;
     169        // CFBundleName code demoted to alternate method because it was causing plist processing issues in Jaguar, yet CopyProcessName doesn't work for everything, e.g. Help Viewer - njr
     170        else if( [self loc] )
     171        {
     172            NSBundle *b = [NSBundle bundleWithPath:loc];
     173            if( b )
     174            {
     175                name = [b localizedStringForKey:@"CFBundleName" value:@"_AsM_nO_nAmE_" table:@"InfoPlist"];
     176
     177                if( [name isEqualToString:@"_AsM_nO_nAmE_"] )
     178                    name = [[b infoDictionary] objectForKey:@"CFBundleName"];
     179
     180                if( name )
     181                    [name retain];
     182            }
     183        }
     184       
     185   }
     186
     187    return name ? name : @"Çunknown nameÈ";
    178188}
    179189
Note: See TracChangeset for help on using the changeset viewer.