• 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: How to check if file exists?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to check if file exists?


  • Subject: Re: How to check if file exists?
  • From: Quincey Morris <email@hidden>
  • Date: Sat, 10 May 2014 16:19:27 -0700

On May 10, 2014, at 15:17 , Charles Srstka <email@hidden> wrote:

> Since that's the case Quincey was talking about (greying out files that don't exist in the UI), I'd say checkResourceIsReachableAndReturnError: is the appropriate API to use. It's certainly more efficient than reading the file just to see if it exists.

It might be the appropriate API, but its semantics are not entirely obvious. The documentation does not make clear what reachability means in the case of a file URL. Presumably, file systems are reachable if and only if they are mounted, but there’s surely a slight discomfort level with such an assumption. Maybe it’s just me.

Anyway, we weren’t suggesting reading the file just to see if it exists. We were suggesting reading the file if you’re going to read the file anyway. If you’re checking for existence, I think -[NSURL getResourceValue:forKey:error:] and -[NSURL resourcesValuesForKeys:error:] are good patterns to keep in mind, because in many cases you actually *do* want to know one or more resource values. For example, you might at least want to know whether the item is a file or a directory.

_______________________________________________

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: How to check if file exists?
      • From: René v Amerongen <email@hidden>
References: 
 >How to check if file exists? (From: William Squires <email@hidden>)
 >Re: How to check if file exists? (From: Quincey Morris <email@hidden>)
 >Re: How to check if file exists? (From: Charles Srstka <email@hidden>)
 >Re: How to check if file exists? (From: Kyle Sluder <email@hidden>)
 >Re: How to check if file exists? (From: Charles Srstka <email@hidden>)

  • Prev by Date: Re: How to check if file exists?
  • Next by Date: Re: How to check if file exists?
  • Previous by thread: Re: How to check if file exists?
  • Next by thread: Re: How to check if file exists?
  • Index(es):
    • Date
    • Thread