Mail Archives: djgpp/1997/09/01/23:32:39
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.
- Raw text -