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.