Typically you use either NSFileManager or NSWorkspace.
To see if a path is a folder/directory, use NSFileManager
's -fileExistsAtPath:isDirectory:
.
To see if a path is a package, use NSWorkspace
's isFilePackageAtPath:
.
I don't know any native Cocoa way to check if a path is an alias (it's a pre-OS X concept...).
I always use Nathan Day's Cocoa wrapper for Alias, NDAlias. See finderInfoFlags:type:creator:
in his NSString
category.
To use it, do
UInt16 flags;
OSType type;
OSType creator;
if([@"/path/to/file" finderInfoFlags:&flags type:&type creator:&creator]){
if(flags&kIsAlias){
the file is an alias...
}
}else{
some error occurred...
}
Well it looks unnecessarily complicated, but that's life. Alias belongs to Classic Mac OS technology, while Cocoa belongs to the NeXTStep heritage.