Message-Id: <199709020331.NAA02744@rabble.uow.edu.au> Subject: Re: file_exists() To: 1pepik AT polbox DOT com (Lukasz Tolwinski) Date: Tue, 2 Sep 1997 13:31:44 +1000 (EST) Cc: djgpp AT delorie DOT com (DJGPP) In-Reply-To: <01bcafe0$a2067ac0$LocalHost@ppp> from Lukasz Tolwinski at "Aug 24, 97 10:22:52 am" From: *** Brett *** MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk What is wrong with using DJGPP's __file_exists(char*) function? Brett > > 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 > But if that file is opened by other program (with permission to be opened only one), > that function returns Access denied. You'll thing that file doesn't exist. > I prefer this function: > It returns non zero if file exists. > The file attribute may contain any of the FA_* constants from dir.h. > > int file_exists(char *filename, int attrib) > { > FILE_SEARCH_STRUCT dta; > errno = FILE_FINDFIRST(filename, attrib, &dta); > return ((errno) ? 0 : -1); > } > > > > > > -- > ********************** Pepik ***************************** > * My e-mail: 1pepik AT polbox DOT com * > * My page: http://free.polbox.pl/1/1pepik * > *********************************************************** > Hieroshima 45 - Czarnobyl 84 - Windows 95... > > -- Brett Porter bporter AT rabble DOT uow DOT edu DOT au http://www.geocities.com/CollegePark/Union/3596 Humour, Programming, and more.