On May 22, 2011, at 11:52 AM, James Merkel wrote: > I would like to add a capability to an application to search > directories and sub-directories eventually opening all image files > (basically using NSDirectoryEnumerator). > Obviously, I can't allow the user to start at say the volume level and > do the search. However as far as I can tell, there is nothing in > NSOpenPanel for example that prevents the user from starting there. I > was trying to come up with a way to prevent the user from starting at > the wrong place. (Putting up an Alert that says you can't start > there). There's a method in the NSFileManager class called > isDeletableFileAtPath. I am thinking that all of those volumes and > higher level directories that I want to avoid are not deletable. > Therefore I could use this as a filter. The only other approach might > be to limit the search to a certain depth (maybe 10 or 20 > directories). However that seems kind of mickey-mouse. Should I be > looking at the lower level File Manager Reference for some help here? > > Has anyone come up with an approach for this?
I have done these types of searches. I could not figure out how to set up the security stuff of entering passwords. You could try the following which should not be too hard to code. I figure everyone has the right to look at what they own so limit the searches by starting them at the user's home file (/Users/"ownerName"). You could test the file name for this "prefix" & proceed if the test passes. You can use the NSString method "hasPrefix:" to do the test. You can probably find the home directory, though I have not tried this lately, by using Foundation functions. Try NSHomeDirectoryForUser(NSUserName()) & see if this helps. Of course, it won't help if you are looking at a flash drive! Good luck. ronald b. kopelman_______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com