class Net::SFTP::Operations::Dir

def glob(path, pattern, flags=0)

it should be able to handle modest numbers of files in each directory.
shallow directory hierarchies with relatively few directories, though
same level of alacrity that ::Dir.glob does; it will work best for
working purely locally, don't expect this method to perform with the
Because working over an SFTP connection is always going to be slower than

be returned in an array when the method finishes.
will be yielded to the block as they are found; otherwise, they will
entries under +path+ against +pattern+. If a block is given, matches
Works as ::Dir.glob, matching (possibly recursively) all directory
def glob(path, pattern, flags=0)
  flags |= ::File::FNM_PATHNAME
  path = path.chop if path.end_with?('/') && path != '/'
  results = [] unless block_given?
  queue = entries(path).reject { |e| %w(. ..).include?(e.name) }
  while queue.any?
    entry = queue.shift
    if entry.directory? && !%w(. ..).include?(::File.basename(entry.name))
      queue += entries("#{path}/#{entry.name}").map do |e|
        e.name.replace("#{entry.name}/#{e.name}")
        e
      end
    end
    if ::File.fnmatch(pattern, entry.name, flags)
      if block_given?
        yield entry
      else
        results << entry
      end
    end
  end
  return results unless block_given?
end