FileTest
implements file test operations similar to those used in File::Stat
.
true
or false
true
if the named file is a block device, false
if it isn't or
if the operating system doesn't support this feature.
FileTest.blockdev?( "testfile" ) → false
true
or false
true
if the named file is a character device, false
if it isn't or
if the operating system doesn't support this feature.
FileTest.chardev?( "/dev/tty" ) → true
true
or false
true
if this named file is a directory, false
otherwise.
FileTest.directory?( "." ) → true
true
or false
true
if the named file is executable.
The tests are made using the effective
owner of the process.
FileTest.executable?( "testfile" ) → false
true
or false
FileTest#executable?
, but tests using the real owner of the
process.
true
or false
true
if the named file exists.
FileTest.exist?( "testfile" ) → true
true
or false
FileTest::exist?
.
true
or false
true
if the named file is a regular file (not a device
file, pipe, socket, etc.).
FileTest.file?( "testfile" ) → true
true
or false
true
if the effective group id of the process is the same
as the group id of the named file.
On Windows NT, returns false
.
FileTest.grpowned?( "/etc/passwd" ) → false
true
or false
true
if the effective user id of the process is the same
as the owner of the named file.
FileTest.owned?( "/etc/passwd" ) → false
true
or false
true
if the operating system supports pipes and
the named file is a pipe, false
otherwise.
FileTest.pipe?( "testfile" ) → false
true
or false
true
if the named file is readable by the effective
user id of this process.
FileTest.readable?( "testfile" ) → true
true
or false
true
if the named file is readable by the real
user id of this process.
FileTest.readable_real?( "testfile" ) → true
true
or false
true
if the named file's set-group-id
permission bit is set, and false
if it isn't or
if the operating system doesn't support this feature.
FileTest.setgid?( "/usr/sbin/lpc" ) → true
true
or false
true
if the named file's set-user-id
permission bit is set, and false
if it isn't or
if the operating system doesn't support this feature.
FileTest.setuid?( "/bin/su" ) → true
FileTest.size( "testfile" ) → 66
nil
nil
if the named file is of zero length; otherwise,
returns a nonzero aFixnum.
FileTest.size?( "testfile" ) → 66
FileTest.size?( "/dev/zero" ) → nil
true
or false
true
if the named file is a socket, false
if
it isn't or
if the operating system doesn't support this feature.
true
or false
true
if the named file has its sticky bit set,
false
if it doesn't or if the operating system doesn't
support this feature.
true
or false
true
if the named file is a symbolic link,
false
if it isn't or if the operating system doesn't
support this feature.
true
or false
true
if the named file is writable by the effective
user id of this process.
true
or false
true
if the named file is writable by the real
user id of this process.
true
or false
true
if the named file is of zero length, false
otherwise.Extracted from the book "Programming Ruby - The Pragmatic Programmer's Guide"
Copyright © 2001 by Addison Wesley Longman, Inc. This material may be distributed only subject to the terms and conditions set forth in the Open Publication License, v1.0 or later (the latest version is presently available at http://www.opencontent.org/openpub/).
Distribution of substantively modified versions of this document is prohibited without the explicit permission of the copyright holder.
Distribution of the work or derivative of the work in any standard (paper) book form is prohibited unless prior permission is obtained from the copyright holder.