• 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: Recursive search for files
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Recursive search for files


  • Subject: Re: Recursive search for files
  • From: James Merkel <email@hidden>
  • Date: Wed, 25 May 2011 19:34:13 -0700

On Wed, 25 May 2011 08:52:31 ronald b. kopelman wrote:

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

Security shouldn't be an issue -- this application is for home use only.
Allowing searches only of the home directory might be a reasonable approach.
I should mention there is some source code that has been out there for a while that does some of what I want to do, it's called "FolderSweep" at
http://www.brockerhoff.net/src/. Might take a look at this a little more.


Thanks,
Jim Merkel

_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Recursive search for files
      • From: Jens Alfke <email@hidden>
    • Re: Recursive search for files
      • From: Kyle Sluder <email@hidden>
  • Prev by Date: Re: NSStream and NSRunModalForWindow
  • Next by Date: Re: Recursive search for files
  • Previous by thread: Re: Recursive search for files
  • Next by thread: Re: Recursive search for files
  • Index(es):
    • Date
    • Thread