Changeset 16 for trunk/Cocoa/F-Script Anywhere/Source/DeVercruesseProcess.m
- Timestamp:
- 10/20/02 04:46:29 (22 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Cocoa/F-Script Anywhere/Source/DeVercruesseProcess.m
r7 r16 20 20 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 21 21 // 02111-1307, USA. 22 23 // njr changes:24 22 25 23 #import "DeVercruesseProcess.h" … … 102 100 - (NSString *)executableLoc; 103 101 { 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); 106 113 107 114 if (bundleRef == NULL) { 115 BOOL isDir; 108 116 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 110 120 } else { 111 121 CFURLRef execURL = CFBundleCopyExecutableURL(bundleRef); … … 144 154 char buffer[1025]; 145 155 CFStringRef pName; 146 NSBundle *b;147 156 148 157 149 158 if( !name ) 150 159 { 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 166 160 if( !name && (CopyProcessName( &psn, &pName) == noErr) ) // with thanks to Dylan Ashe 167 161 { … … 173 167 CFRelease( pName); 174 168 } 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È"; 178 188 } 179 189
Note:
See TracChangeset
for help on using the changeset viewer.