delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/08/23/17:35:04

From: firewind <firewind AT metroid DOT dyn DOT ml DOT org>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: file_exists()
Date: 23 Aug 1997 03:04:24 GMT
Organization: Netcom
Lines: 17
Message-ID: <5tljvo$5si@dfw-ixnews10.ix.netcom.com>
References: <33fdf19a DOT 5293195 AT news DOT telepac DOT pt> <33fe2408 DOT 3775959 AT snews DOT zippo DOT com>
NNTP-Posting-Host: elp-tx2-05.ix.netcom.com
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

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:

<snip>

Keep in mind, however, that access() does not work for device files like
"prn" and "nul", with or without the colon. Network files may not work
either, I can't recall.

late\fw

- Raw text -


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