require 'alib' def dir_size dir size = 0 visited = {} ALib::Util::find2(dir, 'follow' => true) do |path, stat| begin next if visited[stat.ino] next unless stat.file? size += stat.size ensure visited[stat.ino] = true end end size end p dir_size('.')