Charles Mills
6/23/2005 9:54:00 PM
Berger, Daniel wrote:
> > -----Original Message-----
> > From: Brian Takita [mailto:brian.takita@gmail.com]
> > Sent: Thursday, June 23, 2005 3:11 PM
> > To: ruby-talk ML
> > Subject: Dir[] and Windows Network Addresses
> >
> >
> > Hello,
> >
> > Is is possible to get the contents of a Windows network
> > directory using Dir?
> >
> > I would think it would be something like
> > Dir['\\\\Computer\\Dir\\*'] but nothing shows up.
> >
> > Is there a way to access the a Windows network directory
> > without having to call exec 'dir \\\\Computer\\Dir' and
> > parsing the output?
>
> Watch the single versus double quotes. However, that's not the problem
> anway.
>
> Specifying the root makes it fail:
>
> irb(main):019:0> Dir["*.*"]
> => ["AUTOEXEC.BAT", "boot.ini"] # Much snippage
>
> irb(main):016:0> Dir["C:\\*.*"]
> => []
>
> However, Dir.entries should do the trick in the meantime:
>
> irb(main):017:0> Dir.entries("\\\\vadevweb\\public")
> => [".", "..", "Builds", "Devtools", "Projects", "vss"]
>
> Looks like a bug in Dir.glob to me.
Yeah, this is funny:
irb(main):001:0> Dir['C:\\*.*']
=> []
irb(main):002:0> Dir['C:/*.*']
=> ["C:/AUTOEXEC.BAT", "C:/BOOT.INI", "C:/BOOTSECT.DOS",
"C:/COMLOG.txt", "C:/CONFIG.SYS", "C:/DELL.SDR", "C:/hiberfil.sys",
"C:/IO.SYS", "C:/MSDOS.SYS", "C:/NTDETECT.COM", "C:/pagefile.sys",
"C:/volumeid.zbx"]
That was using the irb from the 1-click installer, same thing happens
using Ruby on Cygwin.
-Charlie