www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/1999/05/11/14:14:43

From: Alain Magloire <alainm AT rcsm DOT ece DOT mcgill DOT ca>
Message-Id: <199905111814.OAA22310@mccoy2.ECE.McGill.CA>
Subject: Re: realpath()
To: djgpp-workers AT delorie DOT com
Date: Tue, 11 May 1999 14:14:31 -0400 (EDT)
X-Mailer: ELM [version 2.4 PL25]
MIME-Version: 1.0
Reply-To: djgpp-workers AT delorie DOT com

Bonjour

>  It should be easy to add a simple wrapper around _fixpath.  Volunteers
>  are welcome :

Here is a crude workaround.

-------------
#include <stdlib.h>
char * realpath (const char *, char *);

--------------------------------
#include <stdlib.h>
#include <limits.h>
#include <sys/stat.h>
#include <errno.h>

char * realpath (const char * file_name, char * resolved_name)
{
  struct stat stbuf;

  if (file_name == NULL || resolved_name == NULL)
  {
     errno = EINVAL;
     return 0;
  }

  if (*file_name == '\0')
  {
     errno = ENOENT;
     return 0;
  }

  if (stat(file_name, &stbuf) != 0)
     return 0;

  _fixpath (file_name, resolved_name);
  return resolved_name;
}
--------------------------------

The big difference with _fixpath is that it actually check for 
the path existence.

-- 
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