Class: Sys::Filesystem::Stat
- Inherits:
-
Object
- Object
- Sys::Filesystem::Stat
- Defined in:
- lib/unix/sys/filesystem.rb,
lib/windows/sys/filesystem.rb
Overview
Stat objects are returned by the Sys::Filesystem.stat method.
Constant Summary collapse
- RDONLY =
Read-only filesystem
1
- NOSUID =
Filesystem does not support suid or sgid semantics.
2
- NOTRUNC =
Filesystem does not truncate file names longer than
name_max
. 3
Instance Attribute Summary collapse
-
#base_type ⇒ Object
The file system type, e.g.
-
#block_size ⇒ Object
The file system block size.
-
#blocks ⇒ Object
The total number of blocks available (used or unused) on the file system.
-
#blocks_available ⇒ Object
The total number of unused blocks available to unprivileged processes.
-
#blocks_free ⇒ Object
The total number of unused blocks.
-
#bytes_free ⇒ Object
readonly
Returns the total amount of free space on the partition.
-
#files ⇒ Object
(also: #inodes)
Total number of files/inodes that can be created on the file system.
-
#files_available ⇒ Object
(also: #inodes_available)
Total number of available files/inodes for unprivileged processes that can be created on the file system.
-
#files_free ⇒ Object
(also: #inodes_free)
Total number of free files/inodes that can be created on the file system.
-
#filesystem_id ⇒ Object
The file system volume id.
-
#flags ⇒ Object
A bit mask of file system flags.
-
#fragment_size ⇒ Object
Fragment size.
-
#name_max ⇒ Object
The maximum length of a file name permitted on the file system.
-
#path ⇒ Object
The path of the file system.
Instance Method Summary collapse
-
#bytes_total ⇒ Object
Returns the total space on the partition.
-
#bytes_used ⇒ Object
Returns the total amount of used space on the partition.
-
#initialize ⇒ Stat
constructor
Creates a new Sys::Filesystem::Stat object.
-
#percent_used ⇒ Object
Returns the percentage of the partition that has been used.
Constructor Details
#initialize ⇒ Stat
Creates a new Sys::Filesystem::Stat object. This is meant for internal use only. Do not instantiate directly.
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 |
# File 'lib/unix/sys/filesystem.rb', line 114 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 |
Instance Attribute Details
#base_type ⇒ Object
The file system type, e.g. NTFS, FAT, etc.
105 106 107 |
# File 'lib/unix/sys/filesystem.rb', line 105 def base_type @base_type end |
#block_size ⇒ Object
The file system block size. MS Windows typically defaults to 4096.
72 73 74 |
# File 'lib/unix/sys/filesystem.rb', line 72 def block_size @block_size end |
#blocks ⇒ Object
The total number of blocks available (used or unused) on the file system.
78 79 80 |
# File 'lib/unix/sys/filesystem.rb', line 78 def blocks @blocks end |
#blocks_available ⇒ Object
The total number of unused blocks available to unprivileged processes. Identical to blocks
at the moment.
84 85 86 |
# File 'lib/unix/sys/filesystem.rb', line 84 def blocks_available @blocks_available end |
#blocks_free ⇒ Object
The total number of unused blocks.
81 82 83 |
# File 'lib/unix/sys/filesystem.rb', line 81 def blocks_free @blocks_free end |
#bytes_free ⇒ Object (readonly)
Returns the total amount of free space on the partition.
136 137 138 |
# File 'lib/unix/sys/filesystem.rb', line 136 def bytes_free blocks_available * block_size end |
#files ⇒ Object Also known as: inodes
Total number of files/inodes that can be created on the file system. This attribute is always nil on MS Windows.
87 88 89 |
# File 'lib/unix/sys/filesystem.rb', line 87 def files @files end |
#files_available ⇒ Object Also known as: inodes_available
Total number of available files/inodes for unprivileged processes that can be created on the file system. This attribute is always nil on MS Windows.
93 94 95 |
# File 'lib/unix/sys/filesystem.rb', line 93 def files_available @files_available end |
#files_free ⇒ Object Also known as: inodes_free
Total number of free files/inodes that can be created on the file system. This attribute is always nil on MS Windows.
90 91 92 |
# File 'lib/unix/sys/filesystem.rb', line 90 def files_free @files_free end |
#filesystem_id ⇒ Object
The file system volume id.
96 97 98 |
# File 'lib/unix/sys/filesystem.rb', line 96 def filesystem_id @filesystem_id end |
#flags ⇒ Object
A bit mask of file system flags.
99 100 101 |
# File 'lib/unix/sys/filesystem.rb', line 99 def flags @flags end |
#fragment_size ⇒ Object
Fragment size. Meaningless at the moment.
75 76 77 |
# File 'lib/unix/sys/filesystem.rb', line 75 def fragment_size @fragment_size end |
#name_max ⇒ Object
The maximum length of a file name permitted on the file system.
102 103 104 |
# File 'lib/unix/sys/filesystem.rb', line 102 def name_max @name_max end |
#path ⇒ Object
The path of the file system.
69 70 71 |
# File 'lib/unix/sys/filesystem.rb', line 69 def path @path end |
Instance Method Details
#bytes_total ⇒ Object
Returns the total space on the partition.
131 132 133 |
# File 'lib/unix/sys/filesystem.rb', line 131 def bytes_total blocks * block_size end |
#bytes_used ⇒ Object
Returns the total amount of used space on the partition.
141 142 143 |
# File 'lib/unix/sys/filesystem.rb', line 141 def bytes_used bytes_total - bytes_free end |
#percent_used ⇒ Object
Returns the percentage of the partition that has been used.
146 147 148 |
# File 'lib/unix/sys/filesystem.rb', line 146 def percent_used 100 - (100.0 * bytes_free.to_f / bytes_total.to_f) end |