Method: LinuxStat::Filesystem.used
- Defined in:
- lib/linux_stat/filesystem.rb
.used(fs = ?..freeze) ⇒ Object
used(fs = ‘.’)
Where fs is the directory of the file system (like / or /tmp/ or /run/media/thumbdrive).
It returns the used space of a given disk in bytes.
If the stat can’t be acquired, this method will return nil.
75 76 77 78 79 80 |
# File 'lib/linux_stat/filesystem.rb', line 75 def used(fs = ?..freeze) s = stat_raw(fs) return nil if s.empty? s.default = 0 s[:blocks].-(s[:block_free]) * s[:block_size] end |