Re [ruby-dev:23297] new function for matching path name (and case sensitivity depends on system)

From: "H.Yamamoto" <ocean@...2.ccsnet.ne.jp>
Date: 2004-04-01 11:28:45 UTC
List: ruby-core #2731
Hi, rubyists.

I proposed new function File.match? to match path name 
and that case sensitivity depends on system. (like Dir.glob in 1.9.0).
This function will share implementation with File.fnmatch. Only difference is flags.

  File.match?(.., flags) == File.fnmatch(..., flags | FNM_PATHNAME | (DOSISH ? FNM_CASEFOLD : 0))

Currently, in Windows, if you want to match bitmap file name starting with 'a', and located descendant of
c:/windows, you should write 

  File.fnmatch('c:/windows/**/a*.bmp', your_path, File::FNM_PATHNAME | File::FNM_CASEFOLD)

If File.match? exists, you can write

  File.match?('c:/windows/**/a*.bmp', your_path)

This is shorter. And if you are Windows user, you don't have to spell File::FNM_CASEFOLD any more.

And I like FNM_PATHNAME because I think 'a*.bmp' should not match 'abc/def/ghi/some.bmp' but match 'abc.bmp'.

......

But anyway, I don't use File.fnmatch quite often, and I'm not sure this function is realy useful.
Is this function useful? Any comments will be appliciated.

Thank you.

In This Thread

Prev Next