Check that file exists: Difference between revisions
Content added Content deleted
imported>J7M (add SmallBASIC example) |
(add RPL) |
||
Line 2,779: | Line 2,779: | ||
0 |
0 |
||
</syntaxhighlight> |
</syntaxhighlight> |
||
=={{header|RPL}}== |
|||
The 2 functions below take a word as an argument and return a boolean stating the presence or not of a 'file' (a 'variable' in RPL jargon) or a directory corresponding to the word. |
|||
« VARS SWAP POS |
|||
» '<span style="color:blue">ISHERE?</span>' STO |
|||
« PATH HOME |
|||
VARS ROT POS |
|||
SWAP EVAL <span style="color:grey">@ Back to initial directory</span> |
|||
» '<span style="color:blue">ISHOME?</span>' STO |
|||
=={{header|Ruby}}== |
=={{header|Ruby}}== |
||
<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>. |
<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>. |