Skip to content

Commit

Permalink
Add initial interface for Dir.glob sorting
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergey Fedorov committed Nov 3, 2021
1 parent 09d1b71 commit 66a2eaf
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
6 changes: 3 additions & 3 deletions src/main/ruby/truffleruby/core/dir.rb
Original file line number Diff line number Diff line change
Expand Up @@ -212,18 +212,18 @@ def home(user=nil)
PrivateFile.expand_path("~#{user}")
end

def [](*patterns, base: nil)
def [](*patterns, base: nil, sort: true)
if patterns.size == 1
pattern = Truffle::Type.coerce_to_path(patterns[0], false)
return [] if pattern.empty?
raise ArgumentError, 'nul-separated glob pattern is deprecated' if pattern.include? "\0"
patterns = [pattern]
end

glob patterns, base: base
glob patterns, base: base, sort: sort
end

def glob(pattern, flags=0, base: nil, &block)
def glob(pattern, flags=0, base: nil, sort: true, &block)
if Primitive.object_kind_of?(pattern, Array)
patterns = pattern
else
Expand Down
11 changes: 6 additions & 5 deletions src/main/ruby/truffleruby/core/file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,12 @@ module Constants
W_OK = 2 # test for write permission
R_OK = 4 # test for read permission

FNM_NOESCAPE = 0x01
FNM_PATHNAME = 0x02
FNM_DOTMATCH = 0x04
FNM_CASEFOLD = 0x08
FNM_EXTGLOB = 0x10
FNM_NOESCAPE = 0x01
FNM_PATHNAME = 0x02
FNM_DOTMATCH = 0x04
FNM_CASEFOLD = 0x08
FNM_EXTGLOB = 0x10
FNM_GLOB_NOSORT = 0x40

if Truffle::Platform.windows?
NULL = 'NUL'
Expand Down

0 comments on commit 66a2eaf

Please sign in to comment.