doc
This commit is contained in:
parent
54c6b8c041
commit
59534a04f6
|
@ -2121,7 +2121,12 @@ PREDEFINED = \
|
|||
LOCAL_ARRAY_ARRAY(A, B, C,D):="A B[C][D]"\
|
||||
LOCAL_INIT(A, B, C, D):="A B[C][D]"\
|
||||
LOCAL_INITF(A, B, C):=" A B; C"\
|
||||
LOCAL_INIT_RESTORE(A,B,C,D):="A B; C; D;"\
|
||||
LOCAL_INIT_RESTORE(A,B,C,D):="A B; C; D;" \
|
||||
USES_REGS:="" \
|
||||
USES_REGS1:="void" \
|
||||
PASS_REGS:="" \
|
||||
PASS_REGS1:="" \
|
||||
Yap_InitCPred(Name,Arity,CF,Flags):="/// @cpred Name Arity CF" \
|
||||
PREG:=Yap_REGS.P_
|
||||
|
||||
# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then this
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
}
|
||||
|
||||
.adjust-right {
|
||||
margin-left: 30px !important;
|
||||
font-size: 1.15em !important;
|
||||
margin-left: 20px !important;
|
||||
font-size: 1.00em !important;
|
||||
}
|
||||
|
||||
/* DOXYGEN Code Styles - These are from doxygen but can be changed to fit the theme
|
||||
|
|
|
@ -36,21 +36,22 @@ $( document ).ready(function() {
|
|||
$("div.summary > a").addClass("btn btn-default btn-xs");
|
||||
$("table.fieldtable").addClass("table");
|
||||
$(".fragment").addClass("well");
|
||||
$(".memitem").addClass("panel panel-default");
|
||||
$(".memproto").addClass("panel-heading");
|
||||
$(".memdoc").addClass("panel-body");
|
||||
$("span.mlabel").addClass("label label-info");
|
||||
$(".memitem").addClass("card text-center");
|
||||
$(".memproto").addClass("card-title text-center");
|
||||
$(".memdoc").addClass("card-body text-right);
|
||||
// $("span.mlabel").addClass("card-link label-info");
|
||||
|
||||
|
||||
$("table.memberdecls").addClass("table");
|
||||
$("[class^=memitem]").addClass("active");
|
||||
|
||||
$("div.ah").addClass("btn btn-default");
|
||||
$("span.mlabels").addClass("pull-right");
|
||||
$("table.mlabels").css("width", "100%")
|
||||
$("span.mlabels").css("width", "100%")
|
||||
$("td.mlabels-right").addClass("pull-right");
|
||||
|
||||
$("div.ttc").addClass("panel panel-primary");
|
||||
$("div.ttname").addClass("panel-heading");
|
||||
//$("div.ttname").addClass("panel-heading");
|
||||
$("div.ttname a").css("color", 'white');
|
||||
$("div.ttdef,div.ttdoc,div.ttdeci").addClass("panel-body");
|
||||
|
||||
|
@ -119,4 +120,4 @@ $( document ).ready(function() {
|
|||
$(this).siblings('.memItemRight').remove();
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -109,21 +109,6 @@ This example is equivalent to using the delete_file/1 predicate:
|
|||
~~~~~
|
||||
|
||||
|
||||
*/
|
||||
/** @pred directory_files(+ _Dir_,+ _List_)
|
||||
|
||||
|
||||
Given a directory _Dir_, directory_files/2 procedures a
|
||||
listing of all files and directories in the directory:
|
||||
|
||||
~~~~~
|
||||
?- directory_files('.',L), writeq(L).
|
||||
['Makefile.~1~','sys.so','Makefile','sys.o',x,..,'.']
|
||||
~~~~~
|
||||
The predicates uses the `dirent` family of routines in Unix
|
||||
environments, and `findfirst` in WIN32.
|
||||
|
||||
|
||||
*/
|
||||
/** @pred environ(? _EnvVar_,+ _EnvValue_)
|
||||
|
||||
|
@ -452,13 +437,6 @@ delete_dirfiles([F|Fs], File, Ignore) :-
|
|||
delete_file(TrueF, off, on, Ignore),
|
||||
delete_dirfiles(Fs, File, Ignore).
|
||||
|
||||
directory_files(File, FileList) :-
|
||||
directory_files(File, FileList, on).
|
||||
|
||||
directory_files(File, FileList, Ignore) :-
|
||||
list_directory(File, FileList, Error),
|
||||
handle_system_internal(Error, Ignore, directory_files(File, FileList)).
|
||||
|
||||
handle_system_internal(Error, _Ignore, _G) :- var(Error), !.
|
||||
handle_system_internal(Error, off, G) :- atom(Error), !,
|
||||
throw(error(system_internal(Error),G)).
|
||||
|
@ -708,7 +686,75 @@ get_shell(Shell, '/c') :-
|
|||
get_shell('/bin/sh','-c').
|
||||
|
||||
system :-
|
||||
default_shell(Command),
|
||||
default_shell(C/** @pred directory_files(+ _Dir_,+ _List_)a
|
||||
|
||||
|
||||
Given a directory _Dir_, directory_files/2 procedures a
|
||||
listing of all files and directories in the directory:
|
||||
|
||||
~~~~~
|
||||
?- directory_files('.',L), writeq(L).
|
||||
['Makefile.~1~','sys.so','Makefile','sys.o',x,..,'.']
|
||||
~~~~~
|
||||
The predicates uses the/** @pred directory_files(+ _Dir_,+ _List_)a
|
||||
|
||||
|
||||
Given a directory _Dir_, directory_files/2 procedures a
|
||||
listing of all files and directories in the directory:
|
||||
|
||||
~~~~~
|
||||
?- directory_files('.',L), writeq(L).
|
||||
['Makefile.~1~','sys.so','Makefile','sys.o',x,..,'.']
|
||||
~~~~~
|
||||
The predicates uses the/** @pred directory_files(+ _Dir_,+ _List_)a
|
||||
|
||||
|
||||
Given a directory _Dir_, directory_files/2 procedures a
|
||||
listing of all files and directories in the directory:
|
||||
|
||||
~~~~~
|
||||
?- directory_files('.',L), writeq(L).
|
||||
['Makefile.~1~','sys.so','Makefile','sys.o',x,..,'.']
|
||||
~~~~~
|
||||
The predicates uses the `dirent` family of routines in Unix
|
||||
environments, and `findfirst` in WIN32.
|
||||
|
||||
|
||||
*/
|
||||
`dirent` family of routines in Unix
|
||||
environments, and `findfirst` in WIN32.
|
||||
|
||||
|
||||
*/
|
||||
`dirent` family of routines in Unix
|
||||
environments, and `findfirst` in WIN32.
|
||||
|
||||
|
||||
*/
|
||||
ommand),/** @pred directory_files(+ _Dir_,+ _List_)a
|
||||
|
||||
|
||||
Given a directory _Dir_, directory_files/2 procedures a
|
||||
listing of all files and directories in the directory:
|
||||
|
||||
~~~~~
|
||||
?- directory_files('.',L), writeq(L).
|
||||
['Makefile.~1~','sys.so','Makefile','sys.o',x,..,'.']
|
||||
~~~~~
|
||||
The predicates uses the/** @pred directory_files(+ _Dir_,+ _List_)a
|
||||
|
||||
|
||||
Given a directory _Dir_, directory_files/2 procedures a
|
||||
listing of all files and directories in the directory:
|
||||
|
||||
~~~~~
|
||||
?- directory_files('.',L), writeq(L).
|
||||
['Makefile.~1~','sys.so','Makefile','sys.o',x,..,'.']
|
||||
~~~~~
|
||||
The predicates uses the
|
||||
|
||||
*/
|
||||
|
||||
do_system(Command, _Status, Error),
|
||||
handle_system_internal(Error, off, system).
|
||||
|
||||
|
@ -812,5 +858,22 @@ Passes command _S_ to the Bourne shell (on UNIX environments) or the
|
|||
current command interpreter in WIN32 environments.
|
||||
*/
|
||||
|
||||
/** @pred directory_files(+ _Dir_,+ _List_)a
|
||||
|
||||
|
||||
Given a directory _Dir_, directory_files/2 procedures a
|
||||
listing of all files and directories in the directory:
|
||||
|
||||
~~~~~
|
||||
?- directory_files('.',L), writeq(L).
|
||||
['Makefile.~1~','sys.so','Makefile','sys.o',x,..,'.']
|
||||
~~~~~
|
||||
The predicates uses the `dirent` family of routines in Unix
|
||||
environments, and `findfirst` in WIN32.
|
||||
|
||||
*/
|
||||
directory_files(X,Y) :=
|
||||
list_directory(X,Y).
|
||||
|
||||
/** @} */
|
||||
|
||||
|
|
|
@ -1048,7 +1048,6 @@ X_API void init_sys(void) {
|
|||
#endif
|
||||
YAP_UserCPredicate("datime", datime, 2);
|
||||
YAP_UserCPredicate("mktime", sysmktime, 8);
|
||||
YAP_UserCPredicate("list_directory", list_directory, 3);
|
||||
YAP_UserCPredicate("file_property", file_property, 7);
|
||||
YAP_UserCPredicate("unlink", p_unlink, 2);
|
||||
YAP_UserCPredicate("rmdir", p_rmdir, 2);
|
||||
|
|
83
os/files.c
83
os/files.c
|
@ -27,6 +27,16 @@ static char SccsId[] = "%W% %G%";
|
|||
#include "sysbits.h"
|
||||
#include "yapio.h"
|
||||
|
||||
#if HAVE_DIRENT_H
|
||||
#include <dirent.h>
|
||||
#endif
|
||||
#if HAVE_DIRECT_H
|
||||
#include <direct.h>
|
||||
#endif
|
||||
#if defined(__MINGW32__) || _MSC_VER
|
||||
#include <io.h>
|
||||
#include <windows.h>
|
||||
#endif
|
||||
#if _MSC_VER || defined(__MINGW32__)
|
||||
#define SYSTEM_STAT _stat
|
||||
#else
|
||||
|
@ -624,6 +634,78 @@ static Int file_directory_name(USES_REGS1) { /* file_directory_name(Stream,N) */
|
|||
return Yap_unify(ARG2, MkAtomTerm(Yap_LookupAtom(s)));
|
||||
}
|
||||
|
||||
|
||||
/* Return a list of files for a directory */
|
||||
static Int list_directory(USES_REGS1) {
|
||||
Term tf = MkAtomTerm(Yap_LookupAtom("[]"));
|
||||
yhandle_t sl = Yap_InitSlot(tf);
|
||||
|
||||
char *buf = (char *)AtomName(AtomOfTerm(ARG1));
|
||||
#if defined(__MINGW32__) || _MSC_VER
|
||||
struct _finddata_t c_file;
|
||||
char bs[BUF_SIZE];
|
||||
long hFile;
|
||||
|
||||
bs[0] = '\0';
|
||||
#if HAVE_STRNCPY
|
||||
strncpy(bs, buf, BUF_SIZE);
|
||||
#else
|
||||
strcpy(bs, buf);
|
||||
#endif
|
||||
#if HAVE_STRNCAT
|
||||
strncat(bs, "/*", BUF_SIZE);
|
||||
#else
|
||||
strcat(bs, "/*");
|
||||
#endif
|
||||
if ((hFile = _findfirst(bs, &c_file)) == -1L) {
|
||||
return (Yap_Unify(ARD2, tf));
|
||||
}
|
||||
YAP_PutInSlot(sl, YAP_MkPairTerm(YAP_MkAtomTerm(YAP_LookupAtom(c_file.name)),
|
||||
YAP_GetFromSlot(sl)));
|
||||
while (_findnext(hFile, &c_file) == 0) {
|
||||
YAP_Term ti = YAP_MkAtomTerm(YAP_LookupAtom(c_file.name));
|
||||
YAP_PutInSlot(sl, YAP_MkPairTerm(ti, YAP_GetFromSlot(sl)));
|
||||
}
|
||||
_findclose(hFile);
|
||||
#else
|
||||
#if __ANDROID__
|
||||
{
|
||||
const char *dirName = buf + strlen("/assets/");
|
||||
AAssetManager *mgr = GLOBAL_VFS->priv[0].mgr;
|
||||
AAssetDir *de;
|
||||
const char *dp;
|
||||
|
||||
if ((de = AAssetManager_openDir(mgr, dirName)) == NULL) {
|
||||
return (YAP_Unify(ARD3, YAP_MkIntTerm(errno)));
|
||||
}
|
||||
while ((dp = AAssetDir_getNextFileName(de))) {
|
||||
YAP_Term ti = YAP_MkAtomTerm(YAP_LookupAtom(dp));
|
||||
YAP_PutInSlot(sl, YAP_MkPairTerm(ti, YAP_GetFromSlot(sl)));
|
||||
}
|
||||
AAssetDir_close(de);
|
||||
}
|
||||
#endif
|
||||
#if HAVE_OPENDIR
|
||||
{
|
||||
DIR *de;
|
||||
struct dirent *dp;
|
||||
|
||||
if ((de = opendir(buf)) == NULL) {
|
||||
return (YAP_unify(ARG3, MkIntegerTerm(errno)));
|
||||
}
|
||||
while ((dp = readdir(de))) {
|
||||
Term ti = Yap_MkAtomTerm(Yap_LookupAtom(dp->d_name));
|
||||
Yap_PutInSlot(sl, MkPairTerm(ti, Yap_GetFromSlot(sl)));
|
||||
}
|
||||
closedir(de);
|
||||
}
|
||||
#endif /* HAVE_OPENDIR */
|
||||
#endif
|
||||
tf = Yap_GetFromSlot(sl);
|
||||
return Yap_unify(ARG2, tf);
|
||||
}
|
||||
|
||||
|
||||
static Int same_file(USES_REGS1) {
|
||||
char *f1 = RepAtom(AtomOfTerm(Deref(ARG1)))->StrOfAE;
|
||||
char *f2 = RepAtom(AtomOfTerm(Deref(ARG2)))->StrOfAE;
|
||||
|
@ -714,4 +796,5 @@ void Yap_InitFiles(void) {
|
|||
Yap_InitCPred("file_size", 2, file_size, SafePredFlag | SyncPredFlag);
|
||||
Yap_InitCPred("file_name_extension", 3, file_name_extension,
|
||||
SafePredFlag | SyncPredFlag);
|
||||
YAP_InitPredt("list_directory", list_directory, 2, SyncPredFlag);
|
||||
}
|
||||
|
|
20
pl/setof.yap
20
pl/setof.yap
|
@ -159,12 +159,12 @@ Similar to `bagof( _T_, _G_, _L_)` but sorts list
|
|||
_L_ and keeping only one copy of each element. Again, assuming the
|
||||
same clauses as in the examples above, the reply to the query
|
||||
|
||||
~~~~~
|
||||
~~~
|
||||
setof(X,a(X,Y),L).
|
||||
~~~~~
|
||||
~~~
|
||||
would be:
|
||||
|
||||
~~~~~
|
||||
~~~
|
||||
X = _32
|
||||
Y = 1
|
||||
L = [1,2];
|
||||
|
@ -172,7 +172,7 @@ X = _32
|
|||
Y = 2
|
||||
L = [2];
|
||||
no
|
||||
~~~~~
|
||||
~~~
|
||||
|
||||
|
||||
|
||||
|
@ -202,7 +202,7 @@ For each set of possible instances of the free variables occurring in
|
|||
_T_ satisfying _G_. Again, assuming the same clauses as in the
|
||||
examples above, the reply to the query
|
||||
|
||||
~~~~~
|
||||
~~~
|
||||
bagof(X,a(X,Y),L).
|
||||
|
||||
would be:
|
||||
|
@ -213,7 +213,7 @@ X = _32
|
|||
Y = 2
|
||||
L = [2];
|
||||
no
|
||||
~~~~~
|
||||
~~~
|
||||
|
||||
|
||||
*/
|
||||
|
@ -272,17 +272,17 @@ Similar to `findall( _T_, _G_, _L_)` but eliminate
|
|||
repeated elements. Thus, assuming the same clauses as in the above
|
||||
example, the reply to the query
|
||||
|
||||
~~~~~
|
||||
~~~
|
||||
all(X,a(X,Y),L).
|
||||
~~~~~
|
||||
~~~
|
||||
would be:
|
||||
|
||||
~~~~~
|
||||
~~~
|
||||
X = _32
|
||||
Y = _33
|
||||
L = [2,1];
|
||||
no
|
||||
~~~~~
|
||||
~~~
|
||||
|
||||
Note that all/3 will fail if no answers are found.
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
).
|
||||
|
||||
/**
|
||||
* @defgroup ypp Yap PreProcessing
|
||||
* @defgroup Ypp Yap PreProcessing
|
||||
* @{
|
||||
* @ingroup library
|
||||
*
|
||||
|
|
Reference in New Issue