[comp.sys.mac.programmer] Does file exist in THINK C...

tarr-michael@CS.YALE.EDU (Michael J. Tarr) (05/21/91)

In THINK C (4.0.5) I wish to be able to find out if a file already
exists. In DOS the easy thing to do is access(filename, 0), but I don't
know of a comparable unix or Mac function. Any clues?

-- 
 **************************************************************************
 * Michael J. Tarr                              Department of Psychology  *
 * tarr@cs.yale.edu                             Yale University           *
 **************************************************************************

tonym@polari.UUCP (Tony Mann) (05/21/91)

In article <1991May20.190829.3885@cs.yale.edu> tarr-michael@CS.YALE.EDU (Michael J. Tarr) writes:
>
>In THINK C (4.0.5) I wish to be able to find out if a file already
>exists. In DOS the easy thing to do is access(filename, 0), but I don't
>know of a comparable unix or Mac function. Any clues?

One way is to call FInfo and see if you get an fnfErr (file not found).

glenn@gla-aux.uucp (Glenn Austin) (05/28/91)

In article <1991May20.190829.3885@cs.yale.edu>, tarr-michael@CS.YALE.EDU (Michael J. Tarr) writes:
> In THINK C (4.0.5) I wish to be able to find out if a file already
> exists. In DOS the easy thing to do is access(filename, 0), but I don't
> know of a comparable unix or Mac function. Any clues?

Call GetFInfo on the file, and check the error code.  If it exists, then
noErr is returned.

===============================================================================
| Glenn L. Austin                | "Turn too soon, run out of room.           |
| Macintosh Wizard and           |    Turn too late, much better fate."       |
| Auto Racing Driver             |   -- Jim Russell Racing School Instructors |
|-----------------------------------------------------------------------------|
| Usenet:  glenn@gla-aux.uucp         | CI$:       76354,1434                 |
| GENie:   G.AUSTIN3                  | AOnline:   GAustin                    |
===============================================================================