pathname: Use Dir.children

This commit is contained in:
Nobuyoshi Nakada 2026-05-07 17:16:14 +09:00 committed by Nobuyoshi Nakada
parent 997e11cf37
commit 407398b079
Notes: git 2026-05-13 08:39:01 +00:00

View File

@ -766,15 +766,12 @@ class Pathname
#
def children(with_directory=true)
with_directory = false if @path == '.'
result = []
Dir.foreach(@path) {|e|
next if e == '.' || e == '..'
if with_directory
result << self.class.new(File.join(@path, e))
else
result << self.class.new(e)
end
}
result = Dir.children(@path)
if with_directory
result.map! {|e| self.class.new(File.join(@path, e))}
else
result.map! {|e| self.class.new(e)}
end
result
end