Class | Sys::Filesystem |
In: |
lib/unix/sys/filesystem.rb
lib/windows/sys/filesystem.rb |
Parent: | Object |
The Filesystem class encapsulates information about your filesystem.
VERSION | = | '1.0.0' | The version of the sys-filesystem library. | |
MNT_RDONLY | = | 0x00000001 | ||
MNT_SYNCHRONOUS | = | 0x00000002 | ||
MNT_NOEXEC | = | 0x00000004 | ||
MNT_NOSUID | = | 0x00000008 | ||
MNT_NODEV | = | 0x00000010 | ||
MNT_UNION | = | 0x00000020 | ||
MNT_ASYNC | = | 0x00000040 | ||
MNT_CPROTECT | = | 0x00000080 | ||
MNT_EXPORTED | = | 0x00000100 | ||
MNT_QUARANTINE | = | 0x00000400 | ||
MNT_LOCAL | = | 0x00001000 | ||
MNT_QUOTA | = | 0x00002000 | ||
MNT_ROOTFS | = | 0x00004000 | ||
MNT_DOVOLFS | = | 0x00008000 | ||
MNT_DONTBROWSE | = | 0x00100000 | ||
MNT_IGNORE_OWNERSHIP | = | 0x00200000 | ||
MNT_AUTOMOUNTED | = | 0x00400000 | ||
MNT_JOURNALED | = | 0x00800000 | ||
MNT_NOUSERXATTR | = | 0x01000000 | ||
MNT_DEFWRITE | = | 0x02000000 | ||
MNT_MULTILABEL | = | 0x04000000 | ||
MNT_NOATIME | = | 0x10000000 | ||
MNT_VISFLAGMASK | = | ( MNT_RDONLY | MNT_SYNCHRONOUS | MNT_NOEXEC | MNT_NOSUID | MNT_NODEV | MNT_UNION | MNT_ASYNC | MNT_EXPORTED | MNT_QUARANTINE | MNT_LOCAL | MNT_QUOTA | MNT_ROOTFS | MNT_DOVOLFS | MNT_DONTBROWSE | MNT_IGNORE_OWNERSHIP | MNT_AUTOMOUNTED | MNT_JOURNALED | MNT_NOUSERXATTR | MNT_DEFWRITE | MNT_MULTILABEL | MNT_NOATIME | MNT_CPROTECT | ||
MOUNT_FILE | = | '/etc/mtab' | ||
MOUNT_FILE | = | '/etc/mnttab' | ||
MOUNT_FILE | = | 'getmntinfo' | ||
CASE_SENSITIVE_SEARCH | = | 0x00000001 | ||
CASE_PRESERVED_NAMES | = | 0x00000002 | ||
UNICODE_ON_DISK | = | 0x00000004 | ||
PERSISTENT_ACLS | = | 0x00000008 | ||
FILE_COMPRESSION | = | 0x00000010 | ||
VOLUME_QUOTAS | = | 0x00000020 | ||
SUPPORTS_SPARSE_FILES | = | 0x00000040 | ||
SUPPORTS_REPARSE_POINTS | = | 0x00000080 | ||
SUPPORTS_REMOTE_STORAGE | = | 0x00000100 | ||
VOLUME_IS_COMPRESSED | = | 0x00008000 | ||
SUPPORTS_OBJECT_IDS | = | 0x00010000 | ||
SUPPORTS_ENCRYPTION | = | 0x00020000 | ||
NAMED_STREAMS | = | 0x00040000 | ||
READ_ONLY_VOLUME | = | 0x00080000 | ||
VERSION | = | '1.0.0' | The version of the sys-filesystem library. |
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:\\'
Returns the mount point of the given file, or itself if it cannot be found.
Example:
Sys::Filesystem.mount_point('/home/some_user') # => /home
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 Sys::Filesystem::Stat object containing information about the path on the filesystem.
Returns a Filesystem::Stat object that contains information about the path file system.
Examples:
File.stat("C:\\") File.stat("C:\\Documents and Settings\\some_user")