$dirSize = 0
def process_files(aDir)
totalBytes = 0
Dir.foreach(aDir) do |f|
myPath="#{aDir}\\#{f}"
s = ""
if File.directory?(myPath)
if f!='.' and f!='..'
bytesInDir = process_files(myPath)
puts("<DIR>-->#{myPath} contains [#{bytesInDir}]B")
end
else
fileSize=File.size(myPath)
totalBytes += fileSize
puts("#{myPath}:#{fileSize}B")
end
end
$dirSize += totalBytes
return totalBytes
end
process_files(".")
puts $dirSize
def process_files(aDir)
totalBytes = 0
Dir.foreach(aDir) do |f|
myPath="#{aDir}\\#{f}"
s = ""
if File.directory?(myPath)
if f!='.' and f!='..'
bytesInDir = process_files(myPath)
puts("<DIR>-->#{myPath} contains [#{bytesInDir}]B")
end
else
fileSize=File.size(myPath)
totalBytes += fileSize
puts("#{myPath}:#{fileSize}B")
end
end
$dirSize += totalBytes
return totalBytes
end
process_files(".")
puts $dirSize