Check that file exists: Difference between revisions

Content added Content deleted
(→‎{{header|Euphoria}}: Euphoria example added)
Line 349: Line 349:
require(file.isDirectory(), fn { `$file is not a directory!` })
require(file.isDirectory(), fn { `$file is not a directory!` })
}</lang>
}</lang>

=={{header|Euphoria}}==
<lang euphoria>include file.e

procedure ensure_exists(sequence name)
object x
sequence s
x = dir(name)
if sequence(x) then
if find('d',x[1][D_ATTRIBUTES]) then
s = "directory"
else
s = "file"
end if
printf(1,"%s %s exists.\n",{name,s})
else
printf(1,"%s does not exist.\n",{name})
end if
end procedure

ensure_exists("input.txt")
ensure_exists("docs")
ensure_exists("/input.txt")
ensure_exists("/docs")</lang>


=={{header|F_Sharp|F#}}==
=={{header|F_Sharp|F#}}==