Hi,

On Mon, Feb 20, 2012 at 10:44:31PM +0200, Alon Bar-Lev wrote:
> It still touches the same places...
> 
> The difference is the usage:
> ---
> R_OK|PLATFORM_X_OK
> ---
> or:
> ---
> PLATFORM_MODE_MASK(R_OK | X_OK)
> ---

Nah, that's not the way it should be.

Given that we currently use X_OK only in options.c, and have MANY lines
of the form

    errs |= check_file_access (CHKACC_FILE, options->crl_file, R_OK|X_OK,
                               "--crl-verify directory");

and only a single place where it will actually call access() 
(or _access()), anything that makes all these lines harder to read
is making the code harder to read.  

This code doesn't want or need to know anything about system dependencies, 
that belongs inside check_file_access() - and there you have only a few
access() calls that need to do PLATFORM_MODE_MASK().

Or even better, do it in the openvpn_access() wrapper, in the #ifdef WIN32
code block.  That is the place where the WIN32 pain is, and nobody else
needs to bother.

int
openvpn_access (const char *path, int mode)
{
#ifdef WIN32
  struct gc_arena gc = gc_new ();
  int ret = _waccess (wide_string (path, &gc), (mode & ~X_OK) );
  gc_free (&gc);
  return ret;
#else
  return access (path, mode);
#endif
}

gert


-- 
USENET is *not* the non-clickable part of WWW!
                                                           //www.muc.de/~gert/
Gert Doering - Munich, Germany                             g...@greenie.muc.de
fax: +49-89-35655025                        g...@net.informatik.tu-muenchen.de

Attachment: pgpXUeJghOg_V.pgp
Description: PGP signature

Reply via email to