Module: XcodeTrashRemover::SizeHelper

Defined in:
lib/xcode_trash_remover/size_helper.rb

Class Method Summary collapse

Class Method Details

.dir_size(dir_path) ⇒ Object



7
8
9
10
11
12
13
14
15
16
# File 'lib/xcode_trash_remover/size_helper.rb', line 7

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