class Dir
Public Class Methods
size(dir)
click to toggle source
# File lib/cocoapods_plugin.rb, line 4 def self.size(dir) sum = 0 Dir.foreach(dir) do |entry| begin next if entry =~ /^\./ && entry != '.git' next if entry == "lfs" # 不统计在lfs文件夹下的资源,git clone下载的是lfs内的资源,之后copy到真正目录下,导致大小统计了两次,所以这里不统计lfs目录下的资源 path = File.join(dir, entry) FileTest.directory?(path) ? sum += Dir.size(path) : sum += File.size(path) rescue => exception puts "\e[31mCocoapodsTSPodfileTimeWatch Dir.size error(已捕获): #{exception}\e[0m" next retry end end sum end