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.
314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 |
# File 'lib/unix/sys/filesystem.rb', line 314 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.
305 306 307 |
# File 'lib/unix/sys/filesystem.rb', line 305 def base_type @base_type end |
#block_size ⇒ Object
The file system block size. MS Windows typically defaults to 4096.
272 273 274 |
# File 'lib/unix/sys/filesystem.rb', line 272 def block_size @block_size end |
#blocks ⇒ Object
The total number of blocks available (used or unused) on the file system.
278 279 280 |
# File 'lib/unix/sys/filesystem.rb', line 278 def blocks @blocks end |
#blocks_available ⇒ Object
The total number of unused blocks available to unprivileged processes. Identical to blocks
at the moment.
284 285 286 |
# File 'lib/unix/sys/filesystem.rb', line 284 def blocks_available @blocks_available end |
#blocks_free ⇒ Object
The total number of unused blocks.
281 282 283 |
# File 'lib/unix/sys/filesystem.rb', line 281 def blocks_free @blocks_free end |
#bytes_free ⇒ Object (readonly)
Returns the total amount of free space on the partition.
336 337 338 |
# File 'lib/unix/sys/filesystem.rb', line 336 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.
287 288 289 |
# File 'lib/unix/sys/filesystem.rb', line 287 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.
293 294 295 |
# File 'lib/unix/sys/filesystem.rb', line 293 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.
290 291 292 |
# File 'lib/unix/sys/filesystem.rb', line 290 def files_free @files_free end |
#filesystem_id ⇒ Object
The file system volume id.
296 297 298 |
# File 'lib/unix/sys/filesystem.rb', line 296 def filesystem_id @filesystem_id end |
#flags ⇒ Object
A bit mask of file system flags.
299 300 301 |
# File 'lib/unix/sys/filesystem.rb', line 299 def flags @flags end |
#fragment_size ⇒ Object
Fragment size. Meaningless at the moment.
275 276 277 |
# File 'lib/unix/sys/filesystem.rb', line 275 def fragment_size @fragment_size end |
#name_max ⇒ Object
The maximum length of a file name permitted on the file system.
302 303 304 |
# File 'lib/unix/sys/filesystem.rb', line 302 def name_max @name_max end |
#path ⇒ Object
The path of the file system.
269 270 271 |
# File 'lib/unix/sys/filesystem.rb', line 269 def path @path end |
Instance Method Details
#bytes_total ⇒ Object
Returns the total space on the partition.
331 332 333 |
# File 'lib/unix/sys/filesystem.rb', line 331 def bytes_total blocks * block_size end |
#bytes_used ⇒ Object
Returns the total amount of used space on the partition.
341 342 343 |
# File 'lib/unix/sys/filesystem.rb', line 341 def bytes_used bytes_total - bytes_free end |
#percent_used ⇒ Object
Returns the percentage of the partition that has been used.
346 347 348 |
# File 'lib/unix/sys/filesystem.rb', line 346 def percent_used 100 - (100.0 * bytes_free.to_f / bytes_total.to_f) end |