Built-in Operations on Files

The following operations on files are described in the reference pages.


absolute_file_name(+RelFileName, ?AbsFileName)
takes a filename RelFileName (typically typed in by the user of a program) and unifies it with the normalized AbsFileName.

Beware: absolute_file_name/2 mimics the filename resolution done by commands such as compile/1. It is meant primarily for looking up Prolog source files. If you want to find the absolute filename of any other file, absolute_file_name/2 may not be appropriate. See file_member_of_directory/2 in lib-lfi-fdi.

close(+FileNameOrStream)
if FileNameOrStream is an atom, it refers to a DEC-10-compatible stream connected to the file of that name; otherwise it is a stream object. In either case, the associated stream is closed.
current_stream(?AbsFileName, ?Mode, ?Stream)
is true if Stream is a stream connected to file AbsFileName, and currently open in mode Mode. current_stream/2 can be used to list currently open streams and the files to which they are connected.
library_directory(?Directory)
unifies Directory with an entry from the user-modifiable table of directories to be searched for library files.
open(+FileName, +Mode, -Stream)
opens a new Stream connected to the file named by FileName. If Mode is write (append) it will (may) create a new file.
see(+FileNameOrStream)
opens the file or stream FileNameOrStream for input if it is not already open.
tell(+FileNameOrStream)
opens the file or stream FileNameOrStream for output if it is not already open.
unix(cd(+Directory))
selects Directory as the default directory for relative file names. This is also known as the current working directory. To find out what the default directory currently is, type
          | ?- absolute_file_name(., CurrentDirectory).