=begin
Sat 05 Apr 2008 07:14:20 PM BST
a method to find out the size of a dir
assumptions
- linux OS
=end
# check the OS
if !RUBY_PLATFORM.grep(/linux/)
p "GNU/Linux not detected,\nquitting!"
else
p "GNU/Linux system detected, continuing"
end
# create a top_level directory list
x_dir = Dir.entries("/").grep(/^[[:alpha:]]/).sort
toplevel= x_dir.collect { |xx| "/" + xx}
# test if dirs at the top level exist (a check)
toplevel.each do |dir|
if !File.exist?("#{dir}")
p "directory #{dir} not found!"
end
# detail various info about the dir
print "#{dir}: >>dir? \t #{File.directory?("#{dir}")}\t>>readable? #{File.readable?("#{dir}")}\t size >> #{File.size("#{dir}")}\n"
print "#{Dir.entries("#{dir}")}\t "
end
__END__