Check that file exists: Difference between revisions

Content added Content deleted
(added ocaml)
Line 186: Line 186:
=={{header|Smalltalk}}==
=={{header|Smalltalk}}==


Smalltalk has no notion of 'current directory' because Smalltalk isn't tied to the shell that created it.
Squeak has no notion of 'current directory' because it isn't tied to the shell that created it.

FileDirectory new fileExists: 'c:\serial'.


FileDirectory new fileExists: 'c:\serial'.
(FileDirectory on: 'c:\') directoryExists: 'docs'.
(FileDirectory on: 'c:\') directoryExists: 'docs'.

In GNU Smalltalk instead you can do:

(Directory name: 'c:\docs') exists ifTrue: [ ... ]
(File name: 'c:\serial') isFile ifTrue: [ ... ]

Using ''exists'' in the latter case will return true for directories too.


=={{header|Tcl}}==
=={{header|Tcl}}==