Check that file exists: Difference between revisions
Content added Content deleted
(Added solution in Crystal) |
|||
Line 980: | Line 980: | ||
(print "rel directory exists") |
(print "rel directory exists") |
||
(print "rel directory does not exist"))</lang> |
(print "rel directory does not exist"))</lang> |
||
=={{header|Crystal}}== |
|||
<lang ruby>def check_file(filename : String) |
|||
if File.directory?(filename) |
|||
puts "#{filename} is a directory" |
|||
elsif File.exists?(filename) |
|||
puts "#{filename} is a file" |
|||
else |
|||
puts "#{filename} does not exist" |
|||
end |
|||
end |
|||
check_file("input.txt") |
|||
check_file("docs") |
|||
check_file("/input.txt") |
|||
check_file("/docs")</lang> |
|||
=={{header|D}}== |
=={{header|D}}== |