class Sys::Filesystem::Stat
Stat
objects are returned by the Sys::Filesystem.stat
method.
Constants
- NOSUID
Filesystem
does not support suid or sgid semantics.- NOTRUNC
Filesystem
does not truncate file names longer thanname_max
.- RDONLY
Read-only filesystem
Attributes
The filesystem type, e.g. UFS.
The preferred system block size.
The total number of fragment_size
blocks in the filesystem.
The number of free blocks available to unprivileged processes.
The total number of free blocks in the filesystem.
The total number of files/inodes that can be created.
The number of free files/inodes available to unprivileged processes.
The total number of files/inodes on the filesystem.
The filesystem identifier.
A bit mask of flags.
The fragment size, i.e. fundamental filesystem block size.
The total number of files/inodes that can be created.
The number of free files/inodes available to unprivileged processes.
The total number of files/inodes on the filesystem.
The maximum length of a file name permitted on the filesystem.
The path of the filesystem.
Public Class Methods
Creates a new Sys::Filesystem::Stat
object. This is meant for internal use only. Do not instantiate directly.
# File lib/sys/unix/sys/filesystem.rb, line 115 def initialize @path = nil @block_size = nil @fragment_size = nil @blocks = nil @blocks_free = nil @blocks_available = nil @files = nil @files_free = nil @files_available = nil @filesystem_id = nil @flags = nil @name_max = nil @base_type = nil end
Public Instance Methods
Returns the amount of free space available to unprivileged processes.
# File lib/sys/unix/sys/filesystem.rb, line 142 def bytes_available blocks_available * fragment_size end
Returns the total amount of free space on the partition.
# File lib/sys/unix/sys/filesystem.rb, line 137 def bytes_free blocks_free * fragment_size end
Returns the total space on the partition.
# File lib/sys/unix/sys/filesystem.rb, line 132 def bytes_total blocks * fragment_size end
Returns the total amount of used space on the partition.
# File lib/sys/unix/sys/filesystem.rb, line 147 def bytes_used bytes_total - bytes_free end
Returns true if the filesystem is case sensitive for the current path. Typically this will be any path on MS Windows or Macs using HFS.
For a root path (really any path without actual a-z characters) we take a best guess based on the host operating system. However, as a general rule, I do not recommend using this method for a root path.
# File lib/sys/filesystem.rb, line 28 def case_insensitive? if path !~ /\w+/ if RbConfig::CONFIG['host_os'] =~ /darwin|mac|windows|mswin|mingw/i true # Assumes HFS else false end else File.identical?(path, path.swapcase) end end
Opposite of case_insensitive?
# File lib/sys/filesystem.rb, line 42 def case_sensitive? !case_insensitive? end
Returns the percentage of the partition that has been used.
# File lib/sys/unix/sys/filesystem.rb, line 152 def percent_used 100 - (100.0 * bytes_free.to_f / bytes_total.to_f) end