Ruby/Справочник/FileTest
Класс FileTest
[править]FileTest implements file test operations similar to those used in File::Stat. It exists as a standalone module, and its methods are also insinuated into the File class. (Note that this is not done by inclusion: the interpreter cheats).
Методы объекта
blockdev?, chardev?, directory?, executable?, executable_real?, exist?, exists?, file?, grpowned?, identical?, owned?, pipe?, readable?, readable_real?, setgid?, setuid?, size?, size, socket?, sticky?, symlink?, writable?, writable_real?, zero?
FileTest#blockdev?
[править]File.blockdev?(file_name) => true or false
Returns true if the named file is a block device.
FileTest#chardev?
[править]File.chardev?(file_name) => true or false
Returns true if the named file is a character device.
FileTest#directory?
[править]File.directory?(file_name) => true or false
Returns true if the named file is a directory, false otherwise.
File.directory?(".")
FileTest#executable?
[править]File.executable?(file_name) => true or false
Returns true if the named file is executable by the effective user id of this process.
FileTest#executable_real?
[править]File.executable_real?(file_name) => true or false
Returns true if the named file is executable by the real user id of this process.
FileTest#exist?
[править]File.exist?(file_name) => true or false File.exists?(file_name) => true or false (obsolete)
Return true if the named file exists.
FileTest#exists?
[править]File.exist?(file_name) => true or false File.exists?(file_name) => true or false (obsolete)
Return true if the named file exists.
FileTest#file?
[править]File.file?(file_name) => true or false
Returns true if the named file exists and is a regular file.
FileTest#grpowned?
[править]File.grpowned?(file_name) => true or false
Returns true if the named file exists and the effective group id of the calling process is the owner of the file. Returns false on Windows.
FileTest#identical?
[править]File.identical?(file_1, file_2) => true or false
Returns true if the named files are identical.
open("a", "w") {}
p File.identical?("a", "a") #=> true
p File.identical?("a", "./a") #=> true
File.link("a", "b")
p File.identical?("a", "b") #=> true
File.symlink("a", "c")
p File.identical?("a", "c") #=> true
open("d", "w") {}
p File.identical?("a", "d") #=> false
FileTest#owned?
[править]File.owned?(file_name) => true or false
Returns true if the named file exists and the effective used id of the calling process is the owner of the file.
FileTest#pipe?
[править]File.pipe?(file_name) => true or false
Returns true if the named file is a pipe.
FileTest#readable?
[править]File.readable?(file_name) => true or false
Returns true if the named file is readable by the effective user id of this process.
FileTest#readable_real?
[править]File.readable_real?(file_name) => true or false
Returns true if the named file is readable by the real user id of this process.
FileTest#setgid?
[править]File.setgid?(file_name) => true or false
Returns true if the named file has the setgid bit set.
FileTest#setuid?
[править]File.setuid?(file_name) => true or false
Returns true if the named file has the setuid bit set.
FileTest#size
[править]File.size(file_name) => integer
Returns the size of file_name.
FileTest#size?
[править]File.file?(file_name) => integer or nil
Returns nil if file_name doesn't exist or has zero size, the size of the file otherwise.
FileTest#socket?
[править]File.socket?(file_name) => true or false
Returns true if the named file is a socket.
FileTest#sticky?
[править]File.sticky?(file_name) => true or false
Returns true if the named file has the sticky bit set.
FileTest#symlink?
[править]File.symlink?(file_name) => true or false
Returns true if the named file is a symbolic link.
FileTest#writable?
[править]File.writable?(file_name) => true or false
Returns true if the named file is writable by the effective user id of this process.
FileTest#writable_real?
[править]File.writable_real?(file_name) => true or false
Returns true if the named file is writable by the real user id of this process.
FileTest#zero?
[править]File.zero?(file_name) => true or false
Returns true if the named file exists and has a zero size.