Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , 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 X-Mailer: Mozilla 4.75 [en] (Windows NT 5.0; U) X-Accept-Language: en MIME-Version: 1.0 To: Stephen Gildea 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> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit 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 > #include > #include > #include > > int main(int argc, char *argv[]) > { > char real[512]; > char win32[512]; > int i; > > if (argc != 2) { > fprintf(stderr, "Usage: %s \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