[ Operating System | The ECLiPSe Built-In Predicates | Reference Manual | Alphabetic Index ]

exists(+File)

Succeeds if the file File (with absolute or relative pathname) exists. File can be a directory.
File
Atom or string.

Description

Used to see if the file File exists. File can be a directory. exists(File) is equivalent to get_file_info(File, mode, _).

Modes and Determinism

Fail Conditions

Fails if the file File (with absolute or relative pathname) does not exist

Exceptions

(4) instantiation fault
File is not instantiated.
(5) type error
File is neither an atom nor a string.

Examples

Success:
   [eclipse]: sh('ls myfile').
   myfile
   [eclipse]: exists(myfile).
   yes.

   [eclipse]: sh('ls /home/user/workdir').
   myfile
   [eclipse]: exists('/home/user/workdir').
   yes.

Fail:
   [eclipse]: sh('ls nofile').
   nofile not found
   [eclipse]: exists(nofile).
   no.

Error:
   exists(File).                          (Error 4).
   exists([file]).                        (Error 5).



See Also

existing_file / 4, get_file_info / 3, sh / 1, system / 1, delete / 1, mkdir / 1