• 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: test if folder contains file based on NSURLs
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: test if folder contains file based on NSURLs


  • Subject: Re: test if folder contains file based on NSURLs
  • From: James Bucanek <email@hidden>
  • Date: Fri, 30 Apr 2010 08:13:24 -0700

Rainer Standke <mailto:email@hidden> wrote (Thursday, April 29, 2010 7:59 PM -0700):
I have a bunch of NSURLs for existing files on the system, and a smaller
number of NSRURLs for their enclosing folders. I am looking to determine if a
given file is within a given folder, based on their URLs.

Right now I am thinking that I'll have to create the enclosing folder's URL by
removing the last component, and then compare that to the folder URL.

Is there a better way? Thanks!

Not that I'm aware of. Just make sure the paths are absolute and have been normalized. As others have pointed out, URLs can be relative or contain relative elements (i.e. rel_dir/./dir/../sister_dir/file). Use something like (warning, typed in mail)


NSString* path = [[[url absoluteURL] path] stringByStandardizingPath];

The way I'd do this is convert each URL to an absolute filesystem path. Start by appending a '/' to the end of the enclosing folder's filesystemm path, and then test to see if each target's filesystem path begins with the resulting string.

--
James Bucanek

_______________________________________________

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


References: 
 >test if folder contains file based on NSURLs (From: Rainer Standke <email@hidden>)

  • Prev by Date: Re: Help with threads and queues
  • Next by Date: Re: How to get tapped text from UITextView
  • Previous by thread: Re: test if folder contains file based on NSURLs
  • Next by thread: How to get tapped text from UITextView
  • Index(es):
    • Date
    • Thread