Is File

From SwiftAPI

Jump to: navigation, search

Determine whether a file path is a file

PHP

$path = '/etc/hosts';
$a = is_file($path);
 
$path = '/tmp';
$b = is_file($path);
 
// $a == true
// $b == false

Ruby

ruby-doc.org

path = '/etc/hosts'
a = File.file?(path)
 
path = '/tmp'
b = File.file?(path)
 
# a == true
# b == false
Personal tools