Class: Dir

Inherits:
Object
  • Object
show all
Defined in:
lib/cocoapods_plugin.rb

Class Method Summary collapse

Class Method Details

.size(dir) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# 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