delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2000/10/28/15:27:55

Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT sources DOT redhat DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT sources DOT redhat DOT com>
List-Help: <mailto:cygwin-help AT sources DOT redhat DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT sources DOT redhat DOT com
Delivered-To: mailing list cygwin AT sources DOT redhat DOT com
Message-ID: <39FB2970.6B92D09C@ece.gatech.edu>
Date: Sat, 28 Oct 2000 15:30:56 -0400
From: Charles Wilson <cwilson AT ece DOT gatech DOT edu>
X-Mailer: Mozilla 4.75 [en] (Windows NT 5.0; U)
X-Accept-Language: en
MIME-Version: 1.0
To: Stephen Gildea <gildea AT intouchsys DOT com>
CC: cygwin AT sourceware DOT cygnus DOT com
Subject: Re: sh-utils: need interface to realpath()
References: <200010272122 DOT e9RLMnP11586 AT stay DOT intouchsys DOT com>

cygpath -w {cygwin-path-to-symlink}

result:
 
dos-path-to-real-file.

--Chuck


Stephen Gildea wrote:
> 
> I find I need a simple utility in a shell script: something to read
> through symlinks and give me the true name of a file.  I don't see
> anything in Bash (2.04), sh-utils (2.0), or Cygwin (1.0) that provides
> this functionality.
> 
> There is a common Unix function realpath() that does what I want, but
> it needs to be wrapped in a small utility program.
> 
> I'm not sure where to suggest this utility be added.  We needed it in
> Cygwin to clean Cygwin pathnames of symlinks before passing them to
> native NT programs, so I'm offering this here.
> 
> It is also possible the base GNU shell utilities would be a good place
> to add such a program.
> 
> I'm appending one possible, simple implementation by my co-worker
> Marc Neuberger.  It also handles interpreting the Cygwin root--
> something else we need to expand before we can pass a pathname to
> a native NT process.
> 
>  < Stephen
> 
> #include <stdio.h>
> #include <errno.h>
> #include <sys/cygwin.h>
> #include <unistd.h>
> 
> int main(int argc, char *argv[])
> {
>     char    real[512];
>     char    win32[512];
>     int     i;
> 
>     if (argc != 2) {
>         fprintf(stderr, "Usage: %s <pathname>\n", argv[0]);
>         return 1;
>     }
> 
> 
>     realpath(argv[1], real);
>     cygwin_conv_to_full_win32_path(real, win32);
>     for (i= 0; win32[i]; i++) {
>         if (win32[i] == '\\') {
>             win32[i]= '/';
>         }
>     }
> 
>     printf("%s\n", win32);
> }
> 
> --
> Want to unsubscribe from this list?
> Send a message to cygwin-unsubscribe AT sourceware DOT cygnus DOT com

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe AT sourceware DOT cygnus DOT com

- Raw text -


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