Re: How to check if file exists?

2014-05-10 Thread Quincey Morris
On May 10, 2014, at 15:17 , Charles Srstka 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 s

Re: How to check if file exists?

2014-05-10 Thread Charles Srstka
On May 10, 2014, at 4:32 PM, Kyle Sluder wrote: > On May 10, 2014, at 1:27 PM, Charles Srstka wrote: > >> On May 10, 2014, at 2:25 PM, Quincey Morris >> wrote: >> >>> -[NSFileManager fileExistsAtPath:] is pretty much legacy API nowadays (and >>> it’s significant that there’s no URL-based ve

Re: How to check if file exists?

2014-05-10 Thread koko
Cordially, David Blanton dblan...@britonleap.com On May 10, 2014, at 2:27 PM, Charles Srstka wrote: > Sure there is; -[NSURL checkResourceIsReachableAndReturnError:]. From checkResourceIsReachableAndReturnError: "If your app must perform operations on the file, such as opening it or copyin

Re: How to check if file exists?

2014-05-10 Thread Kyle Sluder
On May 10, 2014, at 1:27 PM, Charles Srstka wrote: > >> On May 10, 2014, at 2:25 PM, Quincey Morris >> wrote: >> >> -[NSFileManager fileExistsAtPath:] is pretty much legacy API nowadays (and >> it’s significant that there’s no URL-based version of it). > > Sure there is; -[NSURL checkResourc

Re: How to check if file exists?

2014-05-10 Thread Charles Srstka
On May 10, 2014, at 2:25 PM, Quincey Morris wrote: > -[NSFileManager fileExistsAtPath:] is pretty much legacy API nowadays (and > it’s significant that there’s no URL-based version of it). Sure there is; -[NSURL checkResourceIsReachableAndReturnError:]. Charles _

Re: How to check if file exists?

2014-05-10 Thread Quincey Morris
On May 10, 2014, at 12:06 , William Squires wrote: > How can I make sure MyFile.txt exists before trying to read it in? You can’t, so don’t even try. :) Because the file system gets modified asynchronously by other processes, there’s always a potential race condition between checking for exist

Re: How to check if file exists?

2014-05-10 Thread Fritz Anderson
On May 10, 2014, at 2:06 PM, William Squires wrote: > If I have an NSString that contains a filename (and possibly a path, as typed > on the command-line), how can I check to see if the specified file actually > exists? [ code fragment that collects a string representing a file name (not an a

How to check if file exists?

2014-05-10 Thread William Squires
If I have an NSString that contains a filename (and possibly a path, as typed on the command-line), how can I check to see if the specified file actually exists? i.e. ... NSString *inFile = [NSString stringWithUTF8String:argv[1]]; ... let's say, and inFile = @"MyFile.txt". How can I make sure