ruby, cygwin and paths

  • Thread starter Guillaume Marcais
  • Start date
G

Guillaume Marcais

This is almost not a ruby question... But I need a ruby solution!

How to convert a 8.3 dos paths to its fully expanded version. For
example, how to translate:

C:\\CYGWIN\\HOME\MYFULL~1\MONROE~9.ALT

to

/cygdrive/c/cygwin/home/My Full Name/Monroe-Tyson.alt

The basename of this last path is relevant to me and while MONROE~9 is
unusable. cygpath -u, from the cygwin distribution, doesn't expand the
8.3 names. It merely changes the \\ into /. How fancy!

Any solution out there?
Guillaume.
 
H

Hal Fulton

Guillaume said:
This is almost not a ruby question... But I need a ruby solution!

How to convert a 8.3 dos paths to its fully expanded version. For
example, how to translate:

C:\\CYGWIN\\HOME\MYFULL~1\MONROE~9.ALT

to

/cygdrive/c/cygwin/home/My Full Name/Monroe-Tyson.alt

The basename of this last path is relevant to me and while MONROE~9 is
unusable. cygpath -u, from the cygwin distribution, doesn't expand the
8.3 names. It merely changes the \\ into /. How fancy!

Any solution out there?

There's always the "ugly" way -- don't say you heard it here.

Something like:

path = `cmd /c dir #{file}`.split("\n")[6][-1]

That's untested.

Hal
 
G

Guillaume Marcais

Guillaume said:
This is almost not a ruby question... But I need a ruby solution!

How to convert a 8.3 dos paths to its fully expanded version. For
example, how to translate:

C:\\CYGWIN\\HOME\MYFULL~1\MONROE~9.ALT

to

/cygdrive/c/cygwin/home/My Full Name/Monroe-Tyson.alt

The basename of this last path is relevant to me and while MONROE~9 is
unusable. cygpath -u, from the cygwin distribution, doesn't expand the
8.3 names. It merely changes the \\ into /. How fancy!

Any solution out there?

There's always the "ugly" way -- don't say you heard it here.

Something like:

path = `cmd /c dir #{file}`.split("\n")[6][-1]

That's untested.

I guess I'll settle for sliglthly improved:

path = `cmd /c dir /b #{file}`

The /b is the bare format: only the name.

Thanks all.
Guillaume.
 
G

Guillaume Marcais

Guillaume said:
This is almost not a ruby question... But I need a ruby solution!

How to convert a 8.3 dos paths to its fully expanded version. For
example, how to translate:

C:\\CYGWIN\\HOME\MYFULL~1\MONROE~9.ALT

to

/cygdrive/c/cygwin/home/My Full Name/Monroe-Tyson.alt

The basename of this last path is relevant to me and while MONROE~9 is
unusable. cygpath -u, from the cygwin distribution, doesn't expand the
8.3 names. It merely changes the \\ into /. How fancy!

Any solution out there?

There's always the "ugly" way -- don't say you heard it here.

Something like:

path = `cmd /c dir #{file}`.split("\n")[6][-1]

That's untested.

I guess I'll settle for sliglthly improved:

path = `cmd /c dir /b #{file}`

The /b is the bare format: only the name.

Thanks all.
Guillaume.
 
D

daz

Guillaume said:
Guillaume said:
This is almost not a ruby question... But I need a ruby solution!

How to convert a 8.3 dos paths to its fully expanded version. For
example, how to translate:

C:\\CYGWIN\\HOME\MYFULL~1\MONROE~9.ALT

to

/cygdrive/c/cygwin/home/My Full Name/Monroe-Tyson.alt

The basename of this last path is relevant to me and while MONROE~9 is
unusable. cygpath -u, from the cygwin distribution, doesn't expand the
8.3 names. It merely changes the \\ into /. How fancy!

Any solution out there?

There's always the "ugly" way -- don't say you heard it here.

Something like:

path = `cmd /c dir #{file}`.split("\n")[6][-1]

That's untested.

I guess I'll settle for sliglthly improved:

path = `cmd /c dir /b #{file}`

The /b is the bare format: only the name.

Thanks all.
Guillaume.

If you wanna see ugly, add this to your list of possible holiday destinations:

http://support.microsoft.com/default.aspx?scid=kb;en-us;154822


#------------------------------------------------------------------------


I don't know if this'll work on cygwin.
On native Win98+, it expands the full path.

#------------------------------------------------------------------------
require 'Win32API'

GetLongPathName = Win32API.new('kernel32', 'GetLongPathName', 'PPL', 'L')

f_short = 'D:\PROGRA~1\BORLAND\CBUILD~1\PROJECTS\CONNEC~1\CONNEC~1.CPP'
f_long = "\0" * 260
flen = GetLongPathName.call(f_short, f_long, f_long.size)
puts f_long[0, flen]

#------------------------------------------------------------------------
#=> D:\Program Files\Borland\CBuilder4\Projects\ConnectLog\ConnectLog.cpp


daz
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top