Daniel Berger
1/8/2009 6:35:00 PM
On Jan 8, 10:44=A0am, bdezo...@wisc.edu wrote:
> Hello,
>
> I am using Ruby 1.8.6-26 on Windows. I have this little test script:
>
> *************************************************************************=
**=AD***************
> system("dir x:\\.\\Radeloff\\Projects\\DATA\\NLCD_2001\\landcover> \nlcd_fg11")
>
> serverDirName =3D "x:/./Radeloff/Projects/DATA_NLCD_2001/landcover/
> nlcd_fg11"
>
> Dir.new(serverDirName).each do | dirEntry |
> =A0 if inHere.nil?
> =A0 =A0 print "Found the directory #{serverDirName} just fine!\n"
> =A0 =A0 inHere =3D true
> =A0 end
> end
> *************************************************************************=
**=AD***************
>
> The first line succeeds. The Dir.new() line bombs out with
> Errno::EINVAL.Note that the Dir.new() code was taken out of a working
> script that works for millions of files and directories except this
> one. The funky "x:/./..." stuff works all the time. I have looked at
> file permissions on the directory in question and it matches other
> directories in the same place that work fine.
>
> Can anyone tell me what could be wrong here? Could this be a Ruby bug?
It's not being caused by the '.'. I just tried it:
irb(main):002:0> Dir.new("C:/staging").each{ |f| p f }
"."
".."
"ptools-1.1.6"
"windows-pr-0.9.8"
"windows-pr-0.9.8.zip"
=3D> #<Dir:0x2e37ea0>
irb(main):003:0> Dir.new("C:/./staging").each{ |f| p f }
"."
".."
"ptools-1.1.6"
"windows-pr-0.9.8"
"windows-pr-0.9.8.zip"
=3D> #<Dir:0x2e32874>
BTW, you can shortcut Dir.new(dir).each with Dir.foreach(dir),
although I don't think it will solve your problem.
Regards,
Dan