• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: How to distinguish if a file is a Document or an Application
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to distinguish if a file is a Document or an Application


  • Subject: Re: How to distinguish if a file is a Document or an Application
  • From: John MacDonnell <email@hidden>
  • Date: Wed, 19 Mar 2003 22:34:01 +0100

This code works:

- (BOOL)isApplicationAtPath:(NSString*)path
{
BOOL isExectutable = [FM isExecutableFileAtPath:path];

if (isExectutable)
{
BOOL isDir;
NSString *path2;
NSString *path3;

// if it is not a directory so is a carbonApp so -> YES
if (! (([FM fileExistsAtPath:path isDirectory:&isDir]) && isDir) )
{
NSDictionary *attributesDic = [FM fileAttributesAtPath:path
traverseLink:NO];

if ([attributesDic fileHFSTypeCode] == 'APPL') // Classic App
return YES;
else
return NO; //NSLog(@"%d", [attributesDic fileHFSTypeCode]); // DEBUG
}

// checking if "/Contents/MacOS" exist so it'll be an application
*for sure* (COCOA App)
path2 = [path stringByAppendingString:@"/Contents/MacOS"];

if ([FM fileExistsAtPath:path2 isDirectory:&isDir] && isDir)
return YES;

path3 = [path stringByAppendingString:@"/Contents/MacOSClassic"]; //
carbon

if ([FM fileExistsAtPath:path3 isDirectory:&isDir] && isDir)
return YES;
}

return NO;
}



>>> Hello gurus,
>>> I'd like to understand from a given path if the file addressed by
>>> the
>>> path is a Document or an Application.
>>>
>>> can you help me in that? the problem is than in Mac OS X applications
>>> are directories (bundle) but they might be single file too if they
>>> are
>>> carbon ones. how to distinguish Apps from directories..
>>>
>>> thanks and see you on WWDC!
>>>
>>> Giovanni
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >Re: How to distinguish if a file is a Document or an Application (From: David Remahl <email@hidden>)

  • Prev by Date: Inactive notification
  • Next by Date: Re: How to distinguish if a file is a Document or an Application
  • Previous by thread: Re: How to distinguish if a file is a Document or an Application
  • Next by thread: Re: How to distinguish if a file is a Document or an Application
  • Index(es):
    • Date
    • Thread