Subject: Re: Path name conversions, Posix <-> Win32
From: [email-masked] (Guy G. Piggford)

15 Jan 1998 03:28:47 -0800
Message-ID: <[email-masked]>
References: <[email-masked]>
Mime-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
To: "Mark Hadfield" <[email-masked]>,
        "Gnu-Win32 Mailing List" <[email-masked]>

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
"[email-masked]" with one line of text: "help".