2 Replies Latest reply: Aug 15, 2011 2:45 PM by Tod Kuykendall
Tod Kuykendall Level 4 Level 4

I'm working through the results of


dirContents = [fManager contentsOfDirectoryAtPath:pathString error:&error];


trying to determine what are Applications and what are folders, but


if (([fManager fileExistsAtPath:tempPathString isDirectory:&isDir]) && isDir){


where tempPathString is pathString appened with the next element of dirContents seems to consistently return YES for isDir when applied to Applications. I realize that applications are folders treated as packages by the Finder but if it returns YES for both how can you tell them apart?


I know that both 10.6 and 10.7 have added routines that return more complex results like enumeratorAtURL:includingPropertiesForKeys:options:errorHandler: but I was hoping to make a single 10.5-7 enumerator so I'd like to figure out how to do it using the 10.5 available tools. I thought some layering of fileExistsAtPath and isExecutableFileAtPath would be the solution but so far that hasn't been the case.


Anyone have any suggestions on how to sort Apps from folders using 10.5 available functions preferably without resorting to suffix checking?





Solved by etresoft on Aug 15, 2011 1:55 PM Solved

According to the documentation for "fileExistsAtPath:isDirectory:"

If you need to further determine if path is a package, use the isFilePackageAtPath: method ofNSWorkspace.