Re: How to check if file exists?
Re: How to check if file exists?
- Subject: Re: How to check if file exists?
- From: René v Amerongen <email@hidden>
- Date: Sun, 11 May 2014 14:42:16 +0200
I really hate it when a file is read for any reasons without reading it.
Some app's do this, then the file info shows that the file is read at that time, without that I opened it.
Specially when I have in the finder a smart folder with read today.
my suggestion.
So is it really only to know for existence of that file, use checkResourceIsReachableAndReturnError.
If you gone read or write to it use the read and write NSURL api's.
HTH
On 11 mei 2014, at 01:19, Quincey Morris <email@hidden> wrote:
> 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