From ac19de91a2259c40e89338ca024068869b90a161 Mon Sep 17 00:00:00 2001 From: ocean Date: Sat, 16 Jul 2005 06:02:19 +0000 Subject: document improvement (backported from HEAD : Austin Ziegler's patch) git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@8778 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- dir.c | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 62 insertions(+), 5 deletions(-) (limited to 'dir.c') diff --git a/dir.c b/dir.c index 183ea05bb7..70c2589945 100644 --- a/dir.c +++ b/dir.c @@ -1298,9 +1298,34 @@ dir_s_aref(obj, str) * Returns the filenames found by expanding the pattern given in * string, either as an array or as parameters to the * block. Note that this pattern is not a regexp (it's closer to a - * shell glob). See File::fnmatch for - * details of file name matching and the meaning of the flags - * parameter. + * shell glob). See File::fnmatch for the meaning of + * the flags parameter. Note that case sensitivity + * depends on your system (so File::FNM_CASEFOLD is ignored) + * + * *:: Matches any file. Can be restricted by + * other values in the glob. * + * will match all files; c* will + * match all files beginning with + * c; *c will match + * all files ending with c; and + * *c* will match all files that + * have c in them (including at + * the beginning or end). Equivalent to + * / .* /x in regexp. + * **:: Matches directories recursively. + * ?:: Matches any one character. Equivalent to + * /.{1}/ in regexp. + * [set]:: Matches any one character in +set+. + * Behaves exactly like character sets in + * Regexp, including set negation + * ([^a-z]). + * {p,q}:: Matches either literal p or + * literal q. Matching literals + * may be more than one character in length. + * More than two literals may be specified. + * Equivalent to pattern alternation in + * regexp. + * \:: Escapes the next metacharacter. * * Dir["config.?"] #=> ["config.h"] * Dir.glob("config.?") #=> ["config.h"] @@ -1310,6 +1335,19 @@ dir_s_aref(obj, str) * Dir.glob("*") #=> ["config.h", "main.rb"] * Dir.glob("*", File::FNM_DOTMATCH) #=> [".", "..", "config.h", "main.rb"] * + * rbfiles = File.join("**", "*.rb") + * Dir.glob(rbfiles) #=> ["main.rb", + * "lib/song.rb", + * "lib/song/karaoke.rb"] + * libdirs = File.join("**", "lib") + * Dir.glob(libdirs) #=> ["lib"] + * + * librbfiles = File.join("**", "lib", "**", "*.rb") + * Dir.glob(librbfiles) #=> ["lib/song.rb", + * "lib/song/karaoke.rb"] + * + * librbfiles = File.join("**", "lib", "*.rb") + * Dir.glob(librbfiles) #=> ["lib/song.rb"] */ static VALUE dir_s_glob(argc, argv, obj) @@ -1402,8 +1440,27 @@ dir_entries(io, dirname) * similar to shell filename globbing. It may contain the following * metacharacters: * - * flags is a bitwise OR of the FNM_xxx parameters. - * The same glob pattern and flags are used by Dir::glob. + * *:: Matches any file. Can be restricted by + * other values in the glob. * + * will match all files; c* will + * match all files beginning with + * c; *c will match + * all files ending with c; and + * *c* will match all files that + * have c in them (including at + * the beginning or end). Equivalent to + * / .* /x in regexp. + * ?:: Matches any one character. Equivalent to + * /.{1}/ in regexp. + * [set]:: Matches any one character in +set+. + * Behaves exactly like character sets in + * Regexp, including set negation + * ([^a-z]). + * \:: Escapes the next metacharacter. + * + * flags is a bitwise OR of the FNM_xxx + * parameters. The same glob pattern and flags are used by + * Dir::glob. * * File.fnmatch('cat', 'cat') #=> true * File.fnmatch('cat', 'category') #=> false -- cgit v1.2.3