Christian von Kleist
12/5/2007 4:51:00 PM
I wrote a simple method for recursively finding the size of a
directory, because I didn't see anything in File::Stat or FileUtils
that does that. Am I missing it? Does Ruby already have an
equivalent to `du`?
def size(f)
return File.size(f) unless File.directory?(f)
Dir.entries(f)[2..-1].inject(0) {|total, s| total + size(File.join(f, s))}
end