Method: LinuxStat::Filesystem.stat
- Defined in:
- lib/linux_stat/filesystem.rb
.stat(fs = ?..freeze) ⇒ Object
stat(fs = ‘.’)
Where fs is the directory of the file system (like / or /tmp/ or /run/media/thumbdrive).
-
It returns a Hash with the following info:
-
total size of the device (in bytes)
-
free space (in kilobytes)
-
used space (in kilobytes)
-
In a hash format:
{:total=>119981191168, :free=>43155574784, :used=>76825616384, :available=>43155574784}
If the stat can’t be acquired, this method will return an empty Hash.
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/linux_stat/filesystem.rb', line 21 def stat(fs = ?..freeze) s = stat_raw(fs) return {} if s.empty? s.default = 0 { total: s[:block_size] * s[:blocks], free: s[:block_size] * s[:block_free], used: s[:blocks].-(s[:block_free]) * s[:block_size] } end |