Skip to content

Instantly share code, notes, and snippets.

@zunda
Created June 2, 2011 01:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zunda/1003762 to your computer and use it in GitHub Desktop.
Save zunda/1003762 to your computer and use it in GitHub Desktop.
あるディレクトリ以下に存在するパスを、文字列の配列として返す
class Dir
def Dir.paths(dirname)
r = Array.new
Dir.foreach(dirname) do |entry|
next if '.' == entry or '..' == entry
path = File.join(dirname, entry)
unless File.directory?(path)
r << path
else
r += Dir.paths(path)
end
end
return r
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment