def glob(path, pattern, flags=0)
flags |= ::File::FNM_PATHNAME
path = path.chop if path[-1,1] == "/"
results = [] unless block_given?
queue = entries(path).reject { |e| e.name == "." || 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