H.Yamamoto
4/3/2005 3:20:00 PM
Hi.
Thomas Sondergaard <ts_news1@sondergaard.cc> wrote:
(2005/04/01 18:54)
>Dir.glob('**/*') matches directories recursively, but
>File.fnmatch('**/*', "a/b/c", File::FNM_PATHNAME) returns false. I
>thought (from reading the docs at ruby-doc.org) that the patterns are
>supposed to be the same.
>
>Can I match directories recursively with File.fnmatch?
Well, File.fnmatch on ruby1.9 works like that.
irb(main):002:0> File.fnmatch('**/*', 'a/b/c', File::FNM_PATHNAME)
=> true
irb(main):003:0> File.fnmatch('a**/*', 'a/b/c', File::FNM_PATHNAME)
=> false
irb(main):004:0> File.fnmatch('**/b*', 'a/b/c', File::FNM_PATHNAME)
=> false
irb(main):005:0> File.fnmatch('**/*', '/a/b/c', File::FNM_PATHNAME)
=> true
irb(main):006:0> File.fnmatch('**/*', 'c:/a/b/c', File::FNM_PATHNAME)
=> true
Does this fit your need?