The Filesystem class serves as an abstract base class. Its methods return objects of other types. Do not instantiate.
| VERSION | = | '1.2.0'.freeze | The version of the sys-filesystem library | |
| MOUNT_FILE | = | '/etc/mtab' | ||
| MOUNT_FILE | = | '/etc/mnttab' | ||
| MOUNT_FILE | = | '/proc/mounts' | ||
| MOUNT_FILE | = | 'getmntinfo' |
Returns the mount point of the given file, or itself if it cannot be found.
Example:
Sys::Filesystem.mount_point('/home/some_user') # => /home
Returns the mount point for the given file. For MS Windows this means the root of the path.
Example:
File.mount_point("C:\\Documents and Settings") # => "C:\\'
In block form, yields a Sys::Filesystem::Mount object for each mounted filesytem on the host. Otherwise it returns an array of Mount objects.
Example:
Sys::Filesystem.mounts{ |fs|
p fs.name # => '/dev/dsk/c0t0d0s0' p fs.mount_time # => Thu Dec 11 15:07:23 -0700 2008 p fs.mount_type # => 'ufs' p fs.mount_point # => '/' p fs.options # => local, noowner, nosuid
}
Yields a Filesystem::Mount object for each volume on your system in block form. Returns an array of Filesystem::Mount objects in non-block form.
Example:
Sys::Filesystem.mounts{ |mount|
p mt.name # => \\Device\\HarddiskVolume1
p mt.mount_point # => C: # p mt.mount_time # => Thu Dec 18 20:12:08 -0700 2008
p mt.mount_type # => NTFS
p mt.options # => casepres,casesens,ro,unicode
p mt.pass_number # => nil
p mt.dump_freq # => nil
}
This method is a bit of a fudge for MS Windows in the name of interface compatibility because this method deals with volumes, not actual mount points. But, I believe it provides the sort of information many users want at a glance.
The possible values for the options and their meanings are as follows:
casepres => The filesystem preserves the case of file names when it places a name on disk. casesens => The filesystem supports case-sensitive file names. compression => The filesystem supports file-based compression. namedstreams => The filesystem supports named streams. pacls => The filesystem preserves and enforces access control lists. ro => The filesystem is read-only. encryption => The filesystem supports the Encrypted File System (EFS). objids => The filesystem supports object identifiers. rpoints => The filesystem supports reparse points. sparse => The filesystem supports sparse files. unicode => The filesystem supports Unicode in file names as they appear on disk. compressed => The filesystem is compressed.
Returns a Filesystem::Stat object that contains information about the path file system. On Windows this will default to using the root path for volume information.
Examples:
Sys::Filesystem.stat("C:\\")
Sys::Filesystem.stat("C:\\Documents and Settings\\some_user")
Returns a Sys::Filesystem::Stat object containing information about the path on the filesystem.