Re: ObjC++ (and a word about Java, too ;-)
Re: ObjC++ (and a word about Java, too ;-)
- Subject: Re: ObjC++ (and a word about Java, too ;-)
- From: "Clark S. Cox III" <email@hidden>
- Date: Wed, 5 Dec 2001 12:43:52 -0500
On Wednesday, December 5, 2001, at 11:32 , Thomas Lachand-Robert wrote:
My code came as follows (probably not the best, but I basically copied
somewhere in the doc):
OSStatus status;
FSRef fsRef;
const char* cname;
FSSpec fsSpec;
FInfo fndrInfo;
cname = [[fullPath stringByExpandingTildeInPath] UTF8String];
status = FSPathMakeRef ((UInt8*) cname, &fsRef, NULL);
if (status == 0)
status = FSGetCatalogInfo (&fsRef, 0, NULL, NULL, &fsSpec, NULL);
if (status == 0)
status = FSpGetFInfo (&fsSpec, &fndrInfo);
if (status == 0) {
macType = fndrInfo.fdType;
macCreator = fndrInfo.fdCreator;
}
It is very difficult to understand what happens. Compare with a similar
piece in Cocoa:
NSDictionary *fattrs = [file attributes];
NSDate* date = [fattrs objectForKey:NSFileModificationDate];
NSString *group = [fattrs objectForKey:NSFileGroupOwnerAccountName];
NSString *owner = [fattrs objectForKey:NSFileOwnerAccountName];
There's always:
NSString *expandedPath = [fullPath stringByExpandingTildeInPath];
NSDictionary *fattrs = [ [ NSFileManager defaultManager ]
fileAttributesAtPath: expandedPath traverseLink: YES ];
macType = [ fattrs fileHFSTypeCode ];
macCreator = [ fattrs fileHFSCreatorCode ];
No need to use Carbon at all.
--
Clark S. Cox, III
email@hidden
http://www.whereismyhead.com/clark/