canonicalize_file_name

Corinna Vinschen corinna-cygwin@cygwin.com
Thu Oct 30 12:10:00 GMT 2008


On Oct 30 05:49, Eric Blake wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> According to John Emmas on 10/30/2008 2:00 AM:
> > On my Linux boxes, /usr/include/stdlib.h declares a function called
> > 'canonicalize_file_name()'.  AFAICT its purpose is to return the
> > absolute path to a file (or folder) after resolving any symbolic links
> > in the supplied path.  Cygwin's stdlib.h doesn't contain this function. 
> > I just wondered if it's available anywhere else or if there's an
> > equivalent function elsewhere.
> 
> Cygwin doesn't (yet) provide it (http://cygwin.com/acronyms/#PTC).  But
> gnulib provides a variant that is used within several cygwin packages:
> http://www.gnu.org/software/gnulib/MODULES.html#module=canonicalize

The following should do the same under Cygwin:

  #include <sys/cygwin.h>
  #include <cygwin/version.h>

  #ifdef CYGWIN_VERSION_DLL_MAJOR >= 1007  /* Cygwin 1.7.0 and later */
    char *out_path = (char *) cygwin_create_path (CCP_WIN_A_TO_POSIX, in_path);
    if (out_path == NULL)
      /* Check errno */
    else
      {
        /* Do what ever you want with out_path. */
	free (out_path);
      }
  #else
    char out_path[PATH_MAX];
    cygwin_conv_to_full_posix_path (in_path, out_path);
  #endif


Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader          cygwin AT cygwin DOT com
Red Hat

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/



More information about the Cygwin mailing list