Name

FileTest — File testing module

Synopsis

The FileTest module contains methods for testing files. The methods in this module are also provided as class methods of the File class.

Module Functions

blockdev?(path)

Returns true if path is a block device.

chardev?(path)

Returns true if path is a character device.

directory?(path)

Returns true if path is a directory.

executable?(path)

Returns true if path is executable.

executable_real?(path)

Returns true if path is executable with real user permissions.

exist?(path)

Returns true if path exists.

file?(path)

Returns true if path is a regular file.

grpowned?(path)

Returns true if path is owned by the user’s group.

owned?(path)

Returns true if path is owned by the effective user.

pipe?(path)

Returns true if path is a pipe.

readable?(path)

Returns true if path is readable.

readable_real?(path)

Returns true if path is readable with real user permissions.

setgid?(path)

Returns true if path’s set-group-id permission bit is set.

setuid?(path)

Returns true if path’s set-user-id permission bit is set.

size(path)

Returns the file size of path.

size?(path)

Returns the file size of path or nil if it’s 0.

socket?(path)

Returns true if path is a socket.

sticky?(path)

Returns true if path’s sticky bit is set.

symlink?(path)

Returns true if path is a symbolic link.

writable?(path)

Returns true if path is writable.

writable_real?(path)

Returns true if path is writable with real user permissions.

zero?(path)

Returns true if the file size of path is 0.

Get Ruby in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.