This is the mail archive of the
cygwin@sourceware.cygnus.com
mailing list for the Cygwin project.
Re: Path name conversions, Posix <-> Win32
- To: "Mark Hadfield" <m dot hadfield at niwa dot cri dot nz>, "Gnu-Win32 Mailing List" <gnu-win32 at cygnus dot com>
- Subject: Re: Path name conversions, Posix <-> Win32
- From: "Guy G. Piggford" <ggp at informix dot com>
- Date: Tue, 13 Jan 1998 12:27:11 -0800
At 10:22 AM 1/13/98 +1300, Mark Hadfield wrote:
>Where can I find command-line utilities for conversion between Cygwin32
>Posix-style and Win32 path names? Eg, a pair of utilities that work like
>this:
>
>bash$ echo //C/foo | win32path
>C:\foo
>bash$ echo C:\\foo | posixpath
>//C/foo
>
>I know it's not too difficult to implement this via string substitution in
>awk or bash. (The above examples are real output, produced by a pair of
>Python scripts that I wrote.) What I really want is something that knows
>about Cygwin32 mounts, eg:
Well you can try something like this:
function win32path
{
declare file=$1
file=$( echo $file | sed -e 's,//\(.\),\1:,' \
`mount | sed -n 's,\([^ ]*\) *\(/[^ ]*\).*,-e s~^\2~\1~,p'` \
-e 's,/,\\,g' \
-e 's,:\([^\\]\),:\\\1,g')
echo $file
}
It doesn't like getting spaces in path names since it only acts upon $1,
but other than that it doesn't do too badly. I'd be interested in any
improvements though, I'm sure that it's probably simpler to do in perl, but
I don't know it well enough.
I've never found a need for the posixpath version so I don't have a canned
one handy.
Guy
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".