Skip to content
Merged

Glob #61

Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions lib/net/sftp/operations/dir.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ def entries(path)
# it should be able to handle modest numbers of files in each directory.
def glob(path, pattern, flags=0)
flags |= ::File::FNM_PATHNAME
path = path.chop if path[-1,1] == "/"
path = path.chop if path.end_with?('/') && path != '/'

results = [] unless block_given?
queue = entries(path).reject { |e| e.name == "." || e.name == ".." }
queue = entries(path).reject { |e| %w(. ..).include?(e.name) }
while queue.any?
entry = queue.shift

Expand Down Expand Up @@ -90,4 +90,4 @@ def [](path, pattern)
end
end

end; end; end
end; end; end