We use the ftype()
function of a File class in Ruby to identify the type of a file. It returns the string file
, directory
, characterSpecial
, blockSpecial
, fifo
, link
, socket
, or unknown
.
File.ftype(file_name)
file_name
: This is the file name whose file type we want to get.
The string returns the string file
, directory
, characterSpecial
, blockSpecial
, fifo
, link
, socket
, or unknown
.
We create some files and our application code main.rb
.