Programming Ruby
The Pragmatic Programmer's Guide
module FileTest
Index:
blockdev?
chardev?
directory?
executable?
executable_real?
exist?
exists?
file?
grpowned?
owned?
pipe?
readable?
readable_real?
setgid?
setuid?
size
size?
socket?
sticky?
symlink?
writable?
writable_real?
zero?
FileTest implements file test operations similar to those used
in
File::Stat.
instance methods
blockdev?
FileTest.blockdev?(
aString )
->
true or
false
Returns
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
chardev?
FileTest.chardev?(
aString )
->
true or
false
Returns
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
directory?
FileTest.directory?(
aString )
->
true or
false
Returns
true if this named file is a directory,
false
otherwise.
FileTest.directory?( "." )
サ
true
executable?
FileTest.executable?(
aString )
->
true or
false
Returns
true if the named file is executable.
The tests are made using the effective
owner of the process.
FileTest.executable?( "testfile" )
サ
false
Same as
FileTest#executable?
, but tests using the real owner of the
process.
exist?
FileTest.exist? (
aString )
->
true or
false
Returns
true if the named file exists.
FileTest.exist?( "testfile" )
サ
true
exists?
FileTest.exists? (
aString )
->
true or
false
Synonym for
FileTest::exist?
.
file?
FileTest.file?(
aString )
->
true or
false
Returns
true if the named file is a regular file (not a device
file, pipe, socket, etc.).
FileTest.file?( "testfile" )
サ
true
grpowned?
FileTest.grpowned?(
aString )
->
true or
false
Returns
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
owned?
FileTest.owned?(
aString )
->
true or
false
Returns
true if the effective user id of the process is the same
as the owner of the named file.
FileTest.owned?( "/etc/passwd" )
サ
false
pipe?
FileTest.pipe?(
aString )
->
true or
false
Returns
true if the operating system supports pipes and
the named file is a pipe,
false otherwise.
FileTest.pipe?( "testfile" )
サ
false
readable?
FileTest.readable?(
aString )
->
true or
false
Returns
true if the named file is readable by the effective
user id of this process.
FileTest.readable?( "testfile" )
サ
true
Returns
true if the named file is readable by the real
user id of this process.
FileTest.readable_real?( "testfile" )
サ
true
setgid?
FileTest.setgid?(
aString )
->
true or
false
Returns
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
setuid?
FileTest.setuid?(
aString )
->
true or
false
Returns
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
size
FileTest.size(
aString )
->
anInteger
Returns the size of the named file in bytes.
FileTest.size( "testfile" )
サ
66
size?
FileTest.size?(
aString )
->
aFixnum or
nil
Returns
nil if the named file is of zero length; otherwise,
returns a nonzero
aFixnum.
FileTest.size?( "testfile" )
サ
66
FileTest.size?( "/dev/zero" )
サ
nil
socket?
FileTest.socket?(
aString )
->
true or
false
Returns
true if the named file is a socket,
false if
it isn't or
if the operating system doesn't support this feature.
sticky?
FileTest.sticky?(
aString )
->
true or
false
Returns
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.
symlink?
FileTest.symlink?(
aString )
->
true or
false
Returns
true if the named file is a symbolic link,
false if it isn't or if the operating system doesn't
support this feature.
writable?
FileTest.writable?(
aString )
->
true or
false
Returns
true if the named file is writable by the effective
user id of this process.
Returns
true if the named file is writable by the real
user id of this process.
zero?
FileTest.zero?(
aString )
->
true or
false
Returns
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.