www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/09/01/23:32:39

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 *** <bporter AT rabble DOT uow DOT edu DOT au>
MIME-Version: 1.0

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019