lib/cli_tools/system.rb
def fs_disk_used( path )
  # First, dereference path
  if File.symlink? path
    p = File.readlink( path )
  else
    p = path
  end
  result = `du -ks #{p} 2>/dev/null`
  size = 0
  result.split("\n").each do |line|
    if m = /(\d+)\s+.*/.match(line)
      size += m[1].to_i*1024
    end
  end
  size
end
# Returns the amount in bytes of used disk space in the specified folder.
#
Returns the amount in bytes of used disk space in the specified folder.
Returns the amount in bytes of used disk space in the specified folder .
def fs_disk_used( path )
  if File.symlink? path
    p = File.readlink( path )
  else
    p = path
  end
  result = `du -ks #{p} 2>/dev/null`
  size = 0
  result.split("\n").each do |line|
    if m = /(\d+)\s+.*/.match(line)
      size += m[1].to_i*1024
    end
  end
  size
end
def fs_disk_used ( path ) if File . symlink? path p = File . readlink ( path ) else p = path end result = ` du -ks  #{ p }  2>/dev/null ` size = 0 result . split ( "\n" ) . each do | line | if m = / ( \d +) \s +.* / . match ( line ) size += m [ 1 ] . to_i * 1024 end end size end
Returns the amount in bytes of used disk space in the specified folder.
Returns the amount in bytes of used disk space in the specified folder .
# First, dereference path
path