cleanups
This commit is contained in:
parent
9fff6e7226
commit
3acf4b3fea
42
pl/os.yap
42
pl/os.yap
@ -9,7 +9,7 @@
|
|||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
:- system_module( '$os', [
|
:- system_module( '$os', [
|
||||||
cd/0,
|
cd/0,
|
||||||
cd/1,
|
cd/1,
|
||||||
getcwd/1,
|
getcwd/1,
|
||||||
@ -24,10 +24,10 @@
|
|||||||
|
|
||||||
%% @{
|
%% @{
|
||||||
|
|
||||||
|
/**
|
||||||
/** @defgroup YAPOS Access to Operating System Functionality
|
@defgroup YAPOS Access to Operating System Functionality
|
||||||
@ingroup builtins
|
@ingroup builtins
|
||||||
|
|
||||||
The following built-in predicates allow access to underlying
|
The following built-in predicates allow access to underlying
|
||||||
Operating System functionality.
|
Operating System functionality.
|
||||||
|
|
||||||
@ -37,38 +37,38 @@ Operating System functionality.
|
|||||||
|
|
||||||
Changes the current directory (on UNIX environments) to the user's home directory.
|
Changes the current directory (on UNIX environments) to the user's home directory.
|
||||||
|
|
||||||
|
|
||||||
*/
|
*/
|
||||||
cd :-
|
cd :-
|
||||||
cd('~').
|
cd('~').
|
||||||
|
|
||||||
/** @pred cd(+ _D_)
|
/** @pred cd(+ _D_)
|
||||||
|
|
||||||
|
|
||||||
Changes the current directory (on UNIX environments).
|
Changes the current directory (on UNIX environments).
|
||||||
|
|
||||||
|
|
||||||
*/
|
*/
|
||||||
cd(F) :-
|
cd(F) :-
|
||||||
absolute_file_name(F, Dir, [file_type(directory),file_errors(fail),access(execute),expand(true)]),
|
absolute_file_name(F, Dir, [file_type(directory),file_errors(fail),access(execute),expand(true)]),
|
||||||
working_directory(_, Dir).
|
working_directory(_, Dir).
|
||||||
|
|
||||||
/** @pred getcwd(- _D_)
|
/** @pred getcwd(- _D_)
|
||||||
|
|
||||||
|
|
||||||
Unify the current directory, represented as an atom, with the argument
|
Unify the current directory, represented as an atom, with the argument
|
||||||
_D_.
|
_D_.
|
||||||
|
|
||||||
|
|
||||||
*/
|
*/
|
||||||
getcwd(Dir) :- working_directory(Dir, Dir).
|
getcwd(Dir) :- working_directory(Dir, Dir).
|
||||||
|
|
||||||
/** @pred ls
|
/** @pred ls
|
||||||
|
|
||||||
|
|
||||||
Prints a list of all files in the current directory.
|
Prints a list of all files in the current directory.
|
||||||
|
|
||||||
|
|
||||||
*/
|
*/
|
||||||
ls :-
|
ls :-
|
||||||
getcwd(X),
|
getcwd(X),
|
||||||
@ -81,7 +81,7 @@ ls :-
|
|||||||
fail.
|
fail.
|
||||||
'$load_system_ls'(X,L) :-
|
'$load_system_ls'(X,L) :-
|
||||||
operating_system_support:directory_files(X, L).
|
operating_system_support:directory_files(X, L).
|
||||||
|
|
||||||
|
|
||||||
'$do_print_files'([]) :-
|
'$do_print_files'([]) :-
|
||||||
nl.
|
nl.
|
||||||
@ -95,18 +95,18 @@ ls :-
|
|||||||
'$do_print_file'(F) :-
|
'$do_print_file'(F) :-
|
||||||
write(F), write(' ').
|
write(F), write(' ').
|
||||||
|
|
||||||
/** @pred pwd
|
/** @pred pwd
|
||||||
|
|
||||||
|
|
||||||
Prints the current directory.
|
Prints the current directory.
|
||||||
|
|
||||||
|
|
||||||
*/
|
*/
|
||||||
pwd :-
|
pwd :-
|
||||||
getcwd(X),
|
getcwd(X),
|
||||||
write(X), nl.
|
write(X), nl.
|
||||||
|
|
||||||
/** @pred unix(+ _S_)
|
/** @pred unix(+ _S_)
|
||||||
|
|
||||||
|
|
||||||
Access to Unix-like functionality:
|
Access to Unix-like functionality:
|
||||||
@ -138,7 +138,7 @@ atoms.
|
|||||||
Execute a new shell.
|
Execute a new shell.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
*/
|
*/
|
||||||
unix(V) :- var(V), !,
|
unix(V) :- var(V), !,
|
||||||
'$do_error'(instantiation_error,unix(V)).
|
'$do_error'(instantiation_error,unix(V)).
|
||||||
@ -188,16 +188,16 @@ unix(putenv(X,Y)) :- '$putenv'(X,Y).
|
|||||||
'$getenv'(X,Y).
|
'$getenv'(X,Y).
|
||||||
'$do_environ'(X, Y) :-
|
'$do_environ'(X, Y) :-
|
||||||
'$do_error'(type_error(atom,X),unix(environ(X,Y))).
|
'$do_error'(type_error(atom,X),unix(environ(X,Y))).
|
||||||
|
|
||||||
|
|
||||||
/** @pred putenv(+ _E_,+ _S_)
|
|
||||||
|
/** @pred putenv(+ _E_,+ _S_)
|
||||||
|
|
||||||
|
|
||||||
Set environment variable _E_ to the value _S_. If the
|
Set environment variable _E_ to the value _S_. If the
|
||||||
environment variable _E_ does not exist, create a new one. Both the
|
environment variable _E_ does not exist, create a new one. Both the
|
||||||
environment variable and the value must be atoms.
|
environment variable and the value must be atoms.
|
||||||
|
|
||||||
|
|
||||||
*/
|
*/
|
||||||
putenv(Na,Val) :-
|
putenv(Na,Val) :-
|
||||||
'$putenv'(Na,Val).
|
'$putenv'(Na,Val).
|
||||||
@ -205,7 +205,7 @@ putenv(Na,Val) :-
|
|||||||
getenv(Na,Val) :-
|
getenv(Na,Val) :-
|
||||||
'$getenv'(Na,Val).
|
'$getenv'(Na,Val).
|
||||||
|
|
||||||
/** @pred setenv(+ _Name_,+ _Value_)
|
/** @pred setenv(+ _Name_,+ _Value_)
|
||||||
|
|
||||||
|
|
||||||
Set environment variable. _Name_ and _Value_ should be
|
Set environment variable. _Name_ and _Value_ should be
|
||||||
@ -213,7 +213,7 @@ instantiated to atoms or integers. The environment variable will be
|
|||||||
passed to `shell/[0-2]` and can be requested using `getenv/2`.
|
passed to `shell/[0-2]` and can be requested using `getenv/2`.
|
||||||
They also influence expand_file_name/2.
|
They also influence expand_file_name/2.
|
||||||
|
|
||||||
|
|
||||||
*/
|
*/
|
||||||
setenv(Na,Val) :-
|
setenv(Na,Val) :-
|
||||||
'$putenv'(Na,Val).
|
'$putenv'(Na,Val).
|
||||||
|
Reference in New Issue
Block a user