module Freespace

Constants

GB
KB
MB
TB
VERSION

Public Class Methods

get_free_space(location,unit=nil) click to toggle source
# File lib/freespace.rb, line 11
def self.get_free_space(location,unit=nil)
  stats = Filesystem.stat(location)
  
  if unit == 'KB'
    free_space = stats.blocks_available * stats.block_size / Freespace::KB
  end

  if unit == 'MB'
    free_space = stats.blocks_available * stats.block_size / Freespace::MB
  end

  if unit == 'GB'
    free_space = stats.blocks_available * stats.block_size / Freespace::GB
  end
  
  if unit == 'TB'
    free_space = stats.blocks_available * stats.block_size / Freespace::TB
  end

  if unit == nil
    unit = 'MB'
    free_space = stats.blocks_available * stats.block_size / Freespace::MB
  end

  free_space_hash = { :free_space => free_space , :unit => unit }
  
  return free_space_hash
end