YAP 7.1.0
Access to Operating System Functionality

The following built-in predicates allow access to underlying Operating System functionality. More...

Detailed Description

The following built-in predicates allow access to underlying Operating System functionality.


Class Documentation

◆ cd/1

class cd/1

cd(+ D)

Changes the current directory (on UNIX environments)

Definition at line 1 of file os.yap.

◆ getcwd/1

class getcwd/1

getcwd(- D)

Unify the current directory, represented as an atom, with the argument D

◆ directory_files/2

class directory_files/2

directory_files(+ Dir,+ List)

directory_files(+-_Dir_,-_List of Files)

Given a directory Dir, directory_files/2 procedures a listing of all fniles and directories in the directory:

?- directory_files('.',L), writeq(L).
['Makefile.~1~','sys.so','Makefile','sys.o',x,..,'.']
directory_files(+ Dir,+ List)

The predicates uses the dirent family of routines in Unix environments, and findfirst in WIN32 through the system_library buil

)

  • If Dir is S valid path to an existing directory, and the current process holds the necessary permission ListOfFiles will be unified with all the files in directory The list of files is not guaranteed to follow any specific order
  • This built-in is just a stub for list_directory/2 It is exported from the user module and from the system library

◆ unix/1

class unix/1

unix(+ S)

Access to Unix-like functionality:

  • argv/1 Return a list of arguments to the program These are the arguments that follow a --, as in the usual Unix convention
  • cd/0 Change to home directory
  • cd/1 Change to given directory Acceptable directory names are strings or atoms
  • environ/2 If the first argument is an atom, unify the second argument with the value of the corresponding environment variable
  • getcwd/1 Unify the first argument with an atom representing the current directory
  • putenv/2 Set environment variable E to the value S If the environment variable E does not exist, create a new one Both the environment variable and the value must be atoms
  • shell/1 Execute command under current shell Acceptable commands are strings or atoms
  • system/1 Execute command with /bin/sh Acceptable commands are strings or atoms
  • shell/0 Execute a new shell

◆ putenv/2

class putenv/2

putenv(+ E,+ S)

Set environment variable E to the value S If the environment variable E does not exist, create a new one Both the environment variable and the value must be atoms

◆ setenv/2

class setenv/2

setenv(+ Name,+ Value)

Set environment variable Name and Value should be instantiated to atoms or integers The environment variable will be passed to shell/[0-2] and can be requested using getenv/2 They also influence expand_file_name/2