[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Is this a Ruby bug in Dir on Windows?

Wayne Magor

10/25/2007 4:42:00 PM

This was discussed on another thread, but I thought I'd ask the question
here to see if this is a bug or if it should work this way.

This line doesn't seem work from the Windows root directory (C:\) but
works from a subdir.

ruby -e 'puts Dir.glob("/**/*.txt")' # Prints nothing


Here's some commentary from the other thread:

On Oct 24, 1:07 pm, Wayne Magor <wemag...@gmail.com> wrote:
> Tim McIntyre wrote:
> > files = Dir.glob("img/**/*.jpg")
>
> Why doesn't that seem to work for me on Windows? Is there something
> different about it on Windows than on Linux?
>
> Is there something different about being at the top-level directory on
> Windows? It's unexpected behavior for me. Why does it operate like
> that?

Looks like it behaves oddly at the root:
C:\>irb
irb(main):001:0> Dir.glob( './**/*.rb' ).length
=> 2
irb(main):002:0> Dir.chdir( 'c:/documents and settings/gavin.kistner/
desktop' )
=> 0
irb(main):003:0> Dir.glob( './**/*.rb' ).length
=> 638
irb(main):004:0> Dir.chdir( 'c:/' )
=> 0
irb(main):005:0> Dir.glob( './**/*.rb' ).length
=> 2
irb(main):006:0> Dir.glob( '.\\**\\*.rb' ).length
=> 0

Further evidence, showing that it's not an issue with ** not diving
more than a couple levels deep:


C:\tmp>irb
irb(main):001:0> Dir.glob( './**/*.rb' )
=> ["./l1/l1.rb", "./l1/l2/l2.rb", "./l1/l2/l3/l3.rb", "./l1/l2/l3/l4/
l4.rb"]
irb(main):002:0> Dir.chdir( '..' )
=> 0
irb(main):003:0> Dir.glob( './**/*.rb' )
=> ["./const_alias1.rb", "./const_alias2.rb"]
irb(main):004:0> Dir.glob( 'tmp/**/*.rb' )
=> ["tmp/l1/l1.rb", "tmp/l1/l2/l2.rb", "tmp/l1/l2/l3/l3.rb", "tmp/l1/
l2/l3/l4/l4.rb"]

Smells like a bug to me, but that's a dangerous claim for someone who
hasn't looked at the implementation. Certainly unexpected behavior by
me, too.
--
Posted via http://www.ruby-....

1 Answer

Michael Linfield

10/25/2007 11:27:00 PM

0

This is an educated guess, but i suspect it has to do with the way
Windows handles accounts. This program at root will try to go into
/documents and settings/administrator , when it trys to access this
folder Windows will deny the program access. So before it hits
administrator or some other folder that Windows wont allow ruby access
to, it may have found 2 .rb (ruby applications) files in say User
Documents.

- Mac
--
Posted via http://www.ruby-....