summaryrefslogtreecommitdiff
path: root/dir.rb
diff options
context:
space:
mode:
Diffstat (limited to 'dir.rb')
-rw-r--r--dir.rb490
1 files changed, 346 insertions, 144 deletions
diff --git a/dir.rb b/dir.rb
index 4d27b0093e..42b475ab2c 100644
--- a/dir.rb
+++ b/dir.rb
@@ -1,92 +1,185 @@
-# Objects of class Dir are directory streams representing
-# directories in the underlying file system. They provide a variety
-# of ways to list directories and their contents. See also File.
+# An object of class \Dir represents a directory in the underlying file system.
#
-# The directory used in these examples contains the two regular files
-# (<code>config.h</code> and <code>main.rb</code>), the parent
-# directory (<code>..</code>), and the directory itself
-# (<code>.</code>).
+# It consists mainly of:
+#
+# - A string _path_, given when the object is created,
+# that specifies a directory in the underlying file system;
+# method #path returns the path.
+# - A collection of string <i>entry names</i>,
+# each of which is the name of a directory or file in the underlying file system;
+# the entry names may be retrieved
+# in an {array-like fashion}[rdoc-ref:Dir@Dir+As+Array-Like]
+# or in a {stream-like fashion}[rdoc-ref:Dir@Dir+As+Stream-Like].
+#
+# == About the Examples
+#
+# Some examples on this page use this simple file tree:
+#
+# example/
+# ├── config.h
+# ├── lib/
+# │ ├── song/
+# │ │ └── karaoke.rb
+# │ └── song.rb
+# └── main.rb
+#
+# Others use the file tree for the
+# {Ruby project itself}[https://github.com/ruby/ruby].
+#
+# == \Dir As \Array-Like
+#
+# A \Dir object is in some ways array-like:
+#
+# - It has instance methods #children, #each, and #each_child.
+# - It includes {module Enumerable}[rdoc-ref:Enumerable@What-27s+Here].
+#
+# == \Dir As Stream-Like
+#
+# A \Dir object is in some ways stream-like.
+#
+# The stream is initially open for reading,
+# but may be closed manually (using method #close),
+# and will be closed on block exit if created by Dir.open called with a block.
+# The closed stream may not be further manipulated,
+# and may not be reopened.
+#
+# The stream has a _position_, which is the index of an entry in the directory:
+#
+# - The initial position is zero (before the first entry).
+# - \Method #tell (aliased as #pos) returns the position.
+# - \Method #pos= sets the position (but ignores a value outside the stream),
+# and returns the position.
+# - \Method #seek is like #pos=, but returns +self+ (convenient for chaining).
+# - \Method #read, if not at end-of-stream, reads the next entry and increments
+# the position;
+# if at end-of-stream, does not increment the position.
+# - \Method #rewind sets the position to zero.
+#
+# Examples (using the {simple file tree}[rdoc-ref:Dir@About+the+Examples]):
+#
+# dir = Dir.new('example') # => #<Dir:example>
+# dir.pos # => 0
+#
+# dir.read # => "."
+# dir.read # => ".."
+# dir.read # => "config.h"
+# dir.read # => "lib"
+# dir.read # => "main.rb"
+# dir.pos # => 5
+# dir.read # => nil
+# dir.pos # => 5
+#
+# dir.rewind # => #<Dir:example>
+# dir.pos # => 0
+#
+# dir.pos = 3 # => 3
+# dir.pos # => 3
+#
+# dir.seek(4) # => #<Dir:example>
+# dir.pos # => 4
+#
+# dir.close # => nil
+# dir.read # Raises IOError.
#
# == What's Here
#
-# \Class \Dir provides methods that are useful for:
+# First, what's elsewhere. \Class \Dir:
+#
+# - Inherits from {class Object}[rdoc-ref:Object@What-27s+Here].
+# - Includes {module Enumerable}[rdoc-ref:Enumerable@What-27s+Here],
+# which provides dozens of additional methods.
+#
+# Here, class \Dir provides methods that are useful for:
#
-# - {Reading}[#class-Dir-label-Reading]
-# - {Setting}[#class-Dir-label-Setting]
-# - {Querying}[#class-Dir-label-Querying]
-# - {Iterating}[#class-Dir-label-Iterating]
-# - {Other}[#class-Dir-label-Other]
+# - {Reading}[rdoc-ref:Dir@Reading]
+# - {Setting}[rdoc-ref:Dir@Setting]
+# - {Querying}[rdoc-ref:Dir@Querying]
+# - {Iterating}[rdoc-ref:Dir@Iterating]
+# - {Other}[rdoc-ref:Dir@Other]
#
# === Reading
#
-# - #close:: Closes the directory stream for +self+.
-# - #pos=:: Sets the position in the directory stream for +self+.
-# - #read:: Reads and returns the next entry in the directory stream for +self+.
-# - #rewind:: Sets the position in the directory stream for +self+ to the first entry.
-# - #seek:: Sets the position in the directory stream for +self+
-# the entry at the given offset.
+# - #close: Closes the directory stream for +self+.
+# - #pos=: Sets the position in the directory stream for +self+.
+# - #read: Reads and returns the next entry in the directory stream for +self+.
+# - #rewind: Sets the position in the directory stream for +self+ to the first entry.
+# - #seek: Sets the position in the directory stream for +self+
+# the entry at the given offset.
#
# === Setting
#
-# - ::chdir:: Changes the working directory of the current process
-# to the given directory.
-# - ::chroot:: Changes the file-system root for the current process
-# to the given directory.
+# - ::chdir: Changes the working directory of the current process
+# to the given directory.
+# - ::chroot: Changes the file-system root for the current process
+# to the given directory.
#
# === Querying
#
-# - ::[]:: Same as ::glob without the ability to pass flags.
-# - ::children:: Returns an array of names of the children
-# (both files and directories) of the given directory,
-# but not including <tt>.</tt> or <tt>..</tt>.
-# - ::empty?:: Returns whether the given path is an empty directory.
-# - ::entries:: Returns an array of names of the children
-# (both files and directories) of the given directory,
-# including <tt>.</tt> and <tt>..</tt>.
-# - ::exist?:: Returns whether the given path is a directory.
-# - ::getwd (aliased as #pwd):: Returns the path to the current working directory.
-# - ::glob:: Returns an array of file paths matching the given pattern and flags.
-# - ::home:: Returns the home directory path for a given user or the current user.
-# - #children:: Returns an array of names of the children
-# (both files and directories) of +self+,
-# but not including <tt>.</tt> or <tt>..</tt>.
-# - #fileno:: Returns the integer file descriptor for +self+.
-# - #path (aliased as #to_path):: Returns the path used to create +self+.
-# - #tell (aliased as #pos):: Returns the integer position
-# in the directory stream for +self+.
+# - ::[]: Same as ::glob without the ability to pass flags.
+# - ::children: Returns an array of names of the children
+# (both files and directories) of the given directory,
+# but not including <tt>.</tt> or <tt>..</tt>.
+# - ::empty?: Returns whether the given path is an empty directory.
+# - ::entries: Returns an array of names of the children
+# (both files and directories) of the given directory,
+# including <tt>.</tt> and <tt>..</tt>.
+# - ::exist?: Returns whether the given path is a directory.
+# - ::getwd (aliased as #pwd): Returns the path to the current working directory.
+# - ::glob: Returns an array of file paths matching the given pattern and flags.
+# - ::home: Returns the home directory path for a given user or the current user.
+# - #children: Returns an array of names of the children
+# (both files and directories) of +self+,
+# but not including <tt>.</tt> or <tt>..</tt>.
+# - #fileno: Returns the integer file descriptor for +self+.
+# - #path (aliased as #to_path): Returns the path used to create +self+.
+# - #tell (aliased as #pos): Returns the integer position
+# in the directory stream for +self+.
#
# === Iterating
#
-# - ::each_child:: Calls the given block with each entry in the given directory,
-# but not including <tt>.</tt> or <tt>..</tt>.
-# - ::foreach:: Calls the given block with each entryin the given directory,
-# including <tt>.</tt> and <tt>..</tt>.
-# - #each:: Calls the given block with each entry in +self+,
-# including <tt>.</tt> and <tt>..</tt>.
-# - #each_child:: Calls the given block with each entry in +self+,
-# but not including <tt>.</tt> or <tt>..</tt>.
+# - ::each_child: Calls the given block with each entry in the given directory,
+# but not including <tt>.</tt> or <tt>..</tt>.
+# - ::foreach: Calls the given block with each entry in the given directory,
+# including <tt>.</tt> and <tt>..</tt>.
+# - #each: Calls the given block with each entry in +self+,
+# including <tt>.</tt> and <tt>..</tt>.
+# - #each_child: Calls the given block with each entry in +self+,
+# but not including <tt>.</tt> or <tt>..</tt>.
#
# === Other
#
-# - ::mkdir:: Creates a directory at the given path, with optional permissions.
-# - ::new:: Returns a new \Dir for the given path, with optional encoding.
-# - ::open:: Same as ::new, but if a block is given, yields the \Dir to the block,
-# closing it upon block exit.
-# - ::unlink (aliased as ::delete and ::rmdir):: Removes the given directory.
-# - #inspect:: Returns a string description of +self+.
+# - ::mkdir: Creates a directory at the given path, with optional permissions.
+# - ::new: Returns a new \Dir for the given path, with optional encoding.
+# - ::open: Same as ::new, but if a block is given, yields the \Dir to the block,
+# closing it upon block exit.
+# - ::unlink (aliased as ::delete and ::rmdir): Removes the given directory.
+# - #inspect: Returns a string description of +self+.
+#
class Dir
- # Dir.open( string ) -> aDir
- # Dir.open( string, encoding: enc ) -> aDir
- # Dir.open( string ) {| aDir | block } -> anObject
- # Dir.open( string, encoding: enc ) {| aDir | block } -> anObject
- #
- # The optional <i>encoding</i> keyword argument specifies the encoding of the directory.
- # If not specified, the filesystem encoding is used.
- #
- # With no block, <code>open</code> is a synonym for Dir::new. If a
- # block is present, it is passed <i>aDir</i> as a parameter. The
- # directory is closed at the end of the block, and Dir::open returns
- # the value of the block.
+ # call-seq:
+ # Dir.open(dirpath) -> dir
+ # Dir.open(dirpath, encoding: nil) -> dir
+ # Dir.open(dirpath) {|dir| ... } -> object
+ # Dir.open(dirpath, encoding: nil) {|dir| ... } -> object
+ #
+ # Creates a new \Dir object _dir_ for the directory at +dirpath+.
+ #
+ # With no block, the method equivalent to Dir.new(dirpath, encoding):
+ #
+ # Dir.open('.') # => #<Dir:.>
+ #
+ # With a block given, the block is called with the created _dir_;
+ # on block exit _dir_ is closed and the block's value is returned:
+ #
+ # Dir.open('.') {|dir| dir.inspect } # => "#<Dir:.>"
+ #
+ # The value given with optional keyword argument +encoding+
+ # specifies the encoding for the directory entry names;
+ # if +nil+ (the default), the file system's encoding is used:
+ #
+ # Dir.open('.').read.encoding # => #<Encoding:UTF-8>
+ # Dir.open('.', encoding: 'US-ASCII').read.encoding # => #<Encoding:US-ASCII>
+ #
def self.open(name, encoding: nil, &block)
dir = Primitive.dir_s_open(name, encoding)
if block
@@ -100,113 +193,222 @@ class Dir
end
end
- # Dir.new( string ) -> aDir
- # Dir.new( string, encoding: enc ) -> aDir
+ # call-seq:
+ # Dir.new(dirpath) -> dir
+ # Dir.new(dirpath, encoding: nil) -> dir
#
- # Returns a new directory object for the named directory.
+ # Returns a new \Dir object for the directory at +dirpath+:
+ #
+ # Dir.new('.') # => #<Dir:.>
+ #
+ # The value given with optional keyword argument +encoding+
+ # specifies the encoding for the directory entry names;
+ # if +nil+ (the default), the file system's encoding is used:
+ #
+ # Dir.new('.').read.encoding # => #<Encoding:UTF-8>
+ # Dir.new('.', encoding: 'US-ASCII').read.encoding # => #<Encoding:US-ASCII>
#
- # The optional <i>encoding</i> keyword argument specifies the encoding of the directory.
- # If not specified, the filesystem encoding is used.
def initialize(name, encoding: nil)
Primitive.dir_initialize(name, encoding)
end
- # Dir[ string [, string ...] [, base: path] [, sort: true] ] -> array
+ # call-seq:
+ # Dir[*patterns, base: nil, sort: true] -> array
+ #
+ # Calls Dir.glob with argument +patterns+
+ # and the values of keyword arguments +base+ and +sort+;
+ # returns the array of selected entry names.
#
- # Equivalent to calling
- # <code>Dir.glob([</code><i>string,...</i><code>], 0)</code>.
def self.[](*args, base: nil, sort: true)
Primitive.dir_s_aref(args, base, sort)
end
- # Dir.glob( pattern, [flags], [base: path] [, sort: true] ) -> array
- # Dir.glob( pattern, [flags], [base: path] [, sort: true] ) { |filename| block } -> nil
+ # call-seq:
+ # Dir.glob(*patterns, flags: 0, base: nil, sort: true) -> array
+ # Dir.glob(*patterns, flags: 0, base: nil, sort: true) {|entry_name| ... } -> nil
#
- # Expands +pattern+, which is a pattern string or an Array of pattern
- # strings, and returns an array containing the matching filenames.
- # If a block is given, calls the block once for each matching filename,
- # passing the filename as a parameter to the block.
+ # Forms an array _entry_names_ of the entry names selected by the arguments.
#
- # The optional +base+ keyword argument specifies the base directory for
- # interpreting relative pathnames instead of the current working directory.
- # As the results are not prefixed with the base directory name in this
- # case, you will need to prepend the base directory name if you want real
- # paths.
+ # Argument +patterns+ is a string pattern or an array of string patterns;
+ # note that these are not regexps; see below.
#
- # The results which matched single wildcard or character set are sorted in
- # binary ascending order, unless false is given as the optional +sort+
- # keyword argument. The order of an Array of pattern strings and braces
- # are preserved.
+ # Notes for the following examples:
#
- # Note that the pattern is not a regexp, it's closer to a shell glob.
- # See File::fnmatch for the meaning of the +flags+ parameter.
- # Case sensitivity depends on your system (File::FNM_CASEFOLD is ignored).
+ # - <tt>'*'</tt> is the pattern that matches any entry name
+ # except those that begin with <tt>'.'</tt>.
+ # - We use method Array#take to shorten returned arrays
+ # that otherwise would be very large.
#
- # <code>*</code>::
- # Matches any file. Can be restricted by other values in the glob.
- # Equivalent to <code>/.*/mx</code> in regexp.
+ # With no block, returns array _entry_names_;
+ # example (using the {simple file tree}[rdoc-ref:Dir@About+the+Examples]):
#
- # <code>*</code>:: Matches all files
- # <code>c*</code>:: Matches all files beginning with <code>c</code>
- # <code>*c</code>:: Matches all files ending with <code>c</code>
- # <code>\*c\*</code>:: Match all files that have <code>c</code> in them
- # (including at the beginning or end).
+ # Dir.glob('*') # => ["config.h", "lib", "main.rb"]
#
- # Note, this will not match Unix-like hidden files (dotfiles). In order
- # to include those in the match results, you must use the
- # File::FNM_DOTMATCH flag or something like <code>"{*,.*}"</code>.
+ # With a block, calls the block with each of the _entry_names_
+ # and returns +nil+:
#
- # <code>**</code>::
- # Matches directories recursively if followed by <code>/</code>. If
- # this path segment contains any other characters, it is the same as the
- # usual <code>*</code>.
+ # Dir.glob('*') {|entry_name| puts entry_name } # => nil
#
- # <code>?</code>::
- # Matches any one character. Equivalent to <code>/.{1}/</code> in regexp.
+ # Output:
#
- # <code>[set]</code>::
- # Matches any one character in +set+. Behaves exactly like character sets
- # in Regexp, including set negation (<code>[^a-z]</code>).
+ # config.h
+ # lib
+ # main.rb
#
- # <code>{p,q}</code>::
- # Matches either literal <code>p</code> or literal <code>q</code>.
- # Equivalent to pattern alternation in regexp.
+ # If optional keyword argument +flags+ is given,
+ # the value modifies the matching; see below.
#
- # Matching literals may be more than one character in length. More than
- # two literals may be specified.
+ # If optional keyword argument +base+ is given,
+ # its value specifies the base directory.
+ # Each pattern string specifies entries relative to the base directory;
+ # the default is <tt>'.'</tt>.
+ # The base directory is not prepended to the entry names in the result:
#
- # <code>\\</code>::
- # Escapes the next metacharacter.
+ # Dir.glob(pattern, base: 'lib').take(5)
+ # # => ["abbrev.gemspec", "abbrev.rb", "base64.gemspec", "base64.rb", "benchmark.gemspec"]
+ # Dir.glob(pattern, base: 'lib/irb').take(5)
+ # # => ["cmd", "color.rb", "color_printer.rb", "completion.rb", "context.rb"]
#
- # Note that this means you cannot use backslash on windows as part of a
- # glob, i.e. <code>Dir["c:\\foo*"]</code> will not work, use
- # <code>Dir["c:/foo*"]</code> instead.
+ # If optional keyword +sort+ is given, its value specifies whether
+ # the array is to be sorted; the default is +true+.
+ # Passing value +false+ with that keyword disables sorting
+ # (though the underlying file system may already have sorted the array).
#
- # Examples:
+ # <b>Patterns</b>
+ #
+ # Each pattern string is expanded
+ # according to certain metacharacters;
+ # examples below use the {Ruby file tree}[rdoc-ref:Dir@About+the+Examples]:
+ #
+ # - <tt>'*'</tt>: Matches any substring in an entry name,
+ # similar in meaning to regexp <tt>/.*/mx</tt>;
+ # may be restricted by other values in the pattern strings:
+ #
+ # - <tt>'*'</tt> matches all entry names:
+ #
+ # Dir.glob('*').take(3) # => ["BSDL", "CONTRIBUTING.md", "COPYING"]
+ #
+ # - <tt>'c*'</tt> matches entry names beginning with <tt>'c'</tt>:
+ #
+ # Dir.glob('c*').take(3) # => ["CONTRIBUTING.md", "COPYING", "COPYING.ja"]
+ #
+ # - <tt>'*c'</tt> matches entry names ending with <tt>'c'</tt>:
+ #
+ # Dir.glob('*c').take(3) # => ["addr2line.c", "array.c", "ast.c"]
+ #
+ # - <tt>'\*c\*'</tt> matches entry names that contain <tt>'c'</tt>,
+ # even at the beginning or end:
+ #
+ # Dir.glob('*c*').take(3) # => ["CONTRIBUTING.md", "COPYING", "COPYING.ja"]
+ #
+ # Does not match Unix-like hidden entry names ("dot files").
+ # To include those in the matched entry names,
+ # use flag IO::FNM_DOTMATCH or something like <tt>'{*,.*}'</tt>.
+ #
+ # - <tt>'**'</tt>: Matches entry names recursively
+ # if followed by the slash character <tt>'/'</tt>:
+ #
+ # Dir.glob('**/').take(3) # => ["basictest/", "benchmark/", "benchmark/gc/"]
+ #
+ # If the string pattern contains other characters
+ # or is not followed by a slash character,
+ # it is equivalent to <tt>'*'</tt>.
+ #
+ # - <tt>'?'</tt> Matches any single character;
+ # similar in meaning to regexp <tt>/./</tt>:
+ #
+ # Dir.glob('io.?') # => ["io.c"]
+ #
+ # - <tt>'[_set_]'</tt>: Matches any one character in the string _set_;
+ # behaves like a {Regexp character class}[rdoc-ref:Regexp@Character+Classes],
+ # including set negation (<tt>'[^a-z]'</tt>):
+ #
+ # Dir.glob('*.[a-z][a-z]').take(3)
+ # # => ["CONTRIBUTING.md", "COPYING.ja", "KNOWNBUGS.rb"]
+ #
+ # - <tt>'{_abc_,_xyz_}'</tt>:
+ # Matches either string _abc_ or string _xyz_;
+ # behaves like {Regexp alternation}[rdoc-ref:Regexp@Alternation]:
+ #
+ # Dir.glob('{LEGAL,BSDL}') # => ["LEGAL", "BSDL"]
+ #
+ # More than two alternatives may be given.
+ #
+ # - <tt>\\</tt>: Escapes the following metacharacter.
+ #
+ # Note that on Windows, the backslash character may not be used
+ # in a string pattern:
+ # <tt>Dir['c:\\foo*']</tt> will not work, use <tt>Dir['c:/foo*']</tt> instead.
+ #
+ # More examples (using the {simple file tree}[rdoc-ref:Dir@About+the+Examples]):
+ #
+ # # We're in the example directory.
+ # File.basename(Dir.pwd) # => "example"
+ # Dir.glob('config.?') # => ["config.h"]
+ # Dir.glob('*.[a-z][a-z]') # => ["main.rb"]
+ # Dir.glob('*.[^r]*') # => ["config.h"]
+ # Dir.glob('*.{rb,h}') # => ["main.rb", "config.h"]
+ # Dir.glob('*') # => ["config.h", "lib", "main.rb"]
+ # Dir.glob('*', File::FNM_DOTMATCH) # => [".", "config.h", "lib", "main.rb"]
+ # Dir.glob(["*.rb", "*.h"]) # => ["main.rb", "config.h"]
+ #
+ # Dir.glob('**/*.rb')
+ # => ["lib/song/karaoke.rb", "lib/song.rb", "main.rb"]
+ #
+ # Dir.glob('**/*.rb', base: 'lib') # => ["song/karaoke.rb", "song.rb"]
+ #
+ # Dir.glob('**/lib') # => ["lib"]
+ #
+ # Dir.glob('**/lib/**/*.rb') # => ["lib/song/karaoke.rb", "lib/song.rb"]
+ #
+ # Dir.glob('**/lib/*.rb') # => ["lib/song.rb"]
+ #
+ # <b>Flags</b>
+ #
+ # If optional keyword argument +flags+ is given (the default is zero -- no flags),
+ # its value should be the bitwise OR of one or more of the constants
+ # defined in module File::Constants.
+ #
+ # Example:
+ #
+ # flags = File::FNM_EXTGLOB | File::FNM_DOTMATCH
+ #
+ # Specifying flags can extend, restrict, or otherwise modify the matching.
+ #
+ # The flags for this method (other constants in File::Constants do not apply):
+ #
+ # - File::FNM_DOTMATCH:
+ # specifies that entry names beginning with <tt>'.'</tt>
+ # should be considered for matching:
+ #
+ # Dir.glob('*').take(5)
+ # # => ["BSDL", "CONTRIBUTING.md", "COPYING", "COPYING.ja", "GPL"]
+ # Dir.glob('*', flags: File::FNM_DOTMATCH).take(5)
+ # # => [".", ".appveyor.yml", ".cirrus.yml", ".dir-locals.el", ".document"]
#
- # Dir["config.?"] #=> ["config.h"]
- # Dir.glob("config.?") #=> ["config.h"]
- # Dir.glob("*.[a-z][a-z]") #=> ["main.rb"]
- # Dir.glob("*.[^r]*") #=> ["config.h"]
- # Dir.glob("*.{rb,h}") #=> ["main.rb", "config.h"]
- # Dir.glob("*") #=> ["config.h", "main.rb"]
- # Dir.glob("*", File::FNM_DOTMATCH) #=> [".", "..", "config.h", "main.rb"]
- # Dir.glob(["*.rb", "*.h"]) #=> ["main.rb", "config.h"]
+ # - File::FNM_EXTGLOB:
+ # enables the pattern extension
+ # <tt>'{_a_,_b_}'</tt>, which matches pattern _a_ and pattern _b_;
+ # behaves like a
+ # {regexp union}[rdoc-ref:Regexp.union]
+ # (e.g., <tt>'(?:_a_|_b_)'</tt>):
#
- # Dir.glob("**/*.rb") #=> ["main.rb",
- # # "lib/song.rb",
- # # "lib/song/karaoke.rb"]
+ # pattern = '{LEGAL,BSDL}'
+ # Dir.glob(pattern) # => ["LEGAL", "BSDL"]
#
- # Dir.glob("**/*.rb", base: "lib") #=> ["song.rb",
- # # "song/karaoke.rb"]
+ # - File::FNM_NOESCAPE:
+ # specifies that escaping with the backslash character <tt>'\'</tt>
+ # is disabled; the character is not an escape character.
#
- # Dir.glob("**/lib") #=> ["lib"]
+ # - File::FNM_PATHNAME:
+ # specifies that metacharacters <tt>'*'</tt> and <tt>'?'</tt>
+ # do not match directory separators.
#
- # Dir.glob("**/lib/**/*.rb") #=> ["lib/song.rb",
- # # "lib/song/karaoke.rb"]
+ # - File::FNM_SHORTNAME:
+ # specifies that patterns may match short names if they exist; Windows only.
#
- # Dir.glob("**/lib/*.rb") #=> ["lib/song.rb"]
def self.glob(pattern, _flags = 0, flags: _flags, base: nil, sort: true)
+ Primitive.attr! :use_block
Primitive.dir_s_glob(pattern, flags, base, sort)
end
end
@@ -224,13 +426,13 @@ class << File
# Matches any file. Can be restricted by other values in the glob.
# Equivalent to <code>/.*/x</code> in regexp.
#
- # <code>*</code>:: Matches all files regular files
+ # <code>*</code>:: Matches all regular files
# <code>c*</code>:: Matches all files beginning with <code>c</code>
# <code>*c</code>:: Matches all files ending with <code>c</code>
# <code>\*c*</code>:: Matches all files that have <code>c</code> in them
# (including at the beginning or end).
#
- # To match hidden files (that start with a <code>.</code> set the
+ # To match hidden files (that start with a <code>.</code>) set the
# File::FNM_DOTMATCH flag.
#
# <code>**</code>::