Added implementation of the SWI-Prolog predicates pwd/0, cd/0, and ls/0 (work in progress).

This commit is contained in:
Paulo Moura 2010-11-09 16:36:22 +00:00
parent bad796702d
commit a0201aa53f
1 changed files with 25 additions and 1 deletions

View File

@ -215,6 +215,30 @@ current_op(X,Y,Z) :-
%%% Operating System utilities
cd :-
cd('~').
ls :-
getcwd(X),
system:directory_files(X, L),
'$do_print_files'(L).
'$do_print_files'([]) :-
nl.
'$do_print_files'([F| Fs]) :-
'$do_print_file'(F),
'$do_print_files'(Fs).
'$do_print_file'('.') :- !.
'$do_print_file'('..') :- !.
'$do_print_file'(F) :- atom_concat('.', _, F), !.
'$do_print_file'(F) :-
write(F), write(' ').
pwd :-
getcwd(X),
write(X), nl.
unix(V) :- var(V), !,
'$do_error'(instantiation_error,unix(V)).
unix(argv(L)) :- '$is_list_of_atoms'(L,L), !, '$argv'(L).