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?
Thank you,
Brian Takita
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.
Regards,
Dan
PS - Find.find seems to handle UNC paths alright, too.
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
At Fri, 24 Jun 2005 06:36:50 +0900,
Berger, Daniel wrote in [ruby-talk:146310]:
> 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.
Not a bug. Backslash is a metacharacter, so you have to use
forward slashes instead.
Dir.entries("//vadevweb/public")
--
Nobu Nakada