Check that file exists: Difference between revisions

Content added Content deleted
(Omitted EasyLang)
m (→‎{{header|Ruby}}: File.exists is deprecated)
Line 2,632: Line 2,632:
</syntaxhighlight>
</syntaxhighlight>
=={{header|Ruby}}==
=={{header|Ruby}}==
<code>File.exists?</code> only checks if a file exists; it can be a regular file, a directory, or something else. <code>File.file?</code> or <code>File.directory?</code> checks for a regular file or a directory. Ruby also allows <code>FileTest.file?</code> or <code>FileTest.directory?</code>.
<code>File.exist?</code> only checks if a file exists; it can be a regular file, a directory, or something else. <code>File.file?</code> or <code>File.directory?</code> checks for a regular file or a directory. Ruby also allows <code>FileTest.file?</code> or <code>FileTest.directory?</code>.


<syntaxhighlight lang="ruby">File.file?("input.txt")
<syntaxhighlight lang="ruby">File.file?("input.txt")
Line 2,645: Line 2,645:
["docs", "/docs"].each { |d|
["docs", "/docs"].each { |d|
printf "%s is a directory? %s\n", d, File.directory?(d) }</syntaxhighlight>
printf "%s is a directory? %s\n", d, File.directory?(d) }</syntaxhighlight>

=={{header|Run BASIC}}==
=={{header|Run BASIC}}==
<syntaxhighlight lang="runbasic">files #f,"input.txt"
<syntaxhighlight lang="runbasic">files #f,"input.txt"