Created
June 2, 2011 01:42
-
-
Save zunda/1003762 to your computer and use it in GitHub Desktop.
あるディレクトリ以下に存在するパスを、文字列の配列として返す
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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