Module: XcodeTrashRemover::SizeHelper
Instance Method Summary collapse
-
#dir_size(dir_path) ⇒ Object
TODO: function to return best size (MB or GB).
Instance Method Details
#dir_size(dir_path) ⇒ Object
TODO: function to return best size (MB or GB).
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/xcode_trash_remover/size_helper.rb', line 10 def dir_size(dir_path) dir_path << '/' unless dir_path.end_with?('/') total_size = 0 if File.directory?(dir_path) Dir["#{dir_path}**/*"].each do |f| total_size += File.size(f) if File.file?(f) && File.size?(f) end end total_size end |