From: adalee AT sendit DOT sendit DOT nodak DOT edu (Adam W Lee) Newsgroups: comp.os.msdos.djgpp Subject: Re: file_exists() Date: 23 Aug 1997 10:02:36 GMT Organization: SENDIT - North Dakota's Educational Network Lines: 30 Message-ID: <5tmcfs$nuo$2@news.sendit.nodak.edu> References: <33fdf19a DOT 5293195 AT news DOT telepac DOT pt> <33fe2408 DOT 3775959 AT snews DOT zippo DOT com> NNTP-Posting-Host: sendit-2.sendit.nodak.edu To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk Peter J. Farley III (pjfarley AT dorsai DOT org) wrote: : Perusing the DJGPP libc sources, it seems to me that access(filename, : R_OK) will give you the results that you want, without the overhead of : an fopen and an fclose. Just call: : access("filename.ext", R_OK) : Zero return value means the file is available for reading, which : implies that it actually exists. So this code should work: : if (access("filename.ext", R_OK)) { : fprint("FILE %s does not exist\n", "filename.ext"); : exit(1); : } : /* From here on we know the file exists... */ Like was already pointed out, this doesn't work over networks sometimes, etc... Also, if the read permission were turned off it would deny you. I would take a look at findfirst(); -- +--- -- -- - - | [pHiXx/VorteX] : phixx AT usa DOT net : .