www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/1999/05/12/10:32:13

From: Alain Magloire <alainm AT rcsm DOT ece DOT mcgill DOT ca>
Message-Id: <199905121431.KAA24819@mccoy2.ECE.McGill.CA>
Subject: Re: realpath()
To: eliz AT is DOT elta DOT co DOT il (Eli Zaretskii)
Date: Wed, 12 May 1999 10:31:50 -0400 (EDT)
Cc: djgpp-workers AT delorie DOT com
In-Reply-To: <Pine.SUN.3.91.990512100227.20820P-100000@is> from "Eli Zaretskii" at May 12, 99 10:03:11 am
X-Mailer: ELM [version 2.4 PL25]
MIME-Version: 1.0
Reply-To: djgpp-workers AT delorie DOT com
X-Mailing-List: djgpp-workers AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

Bonjour

> >   if (stat(file_name, &stbuf) != 0)
> >      return 0;
> 
> `stat' is too expensive for this.  Use `__file_exist' or `access'
> instead.  (I think `access' is a better alternative for
> Unix-compatibility functions, since it doesn't fail for root
> directories and devices.)

I'm not sure about __file_exist, since, according to reference
on www.delorie.com/djgpp/doc/libc it does not seem to set the errno
appropriately.

realpath() is use to kill two birds with one stone.
Canonize the path and checking for accessibility of the file.

I agree, access() will do nicely to.

#include <unistd.h>
...
if (access(file_name, R_OK) != 0)
	return NULL;
...

-- 
au revoir, alain
----
Aussi haut que l'on soit assis, on est toujours assis que sur son cul !!!

- Raw text -


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