take care of the case where two files have different names but

are the same (at least for Unix/Linux).
recover $loaded space after initialisation.


git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@488 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
vsc
2002-05-24 03:57:20 +00:00
parent 03231bef34
commit 38f07b67de
5 changed files with 47 additions and 16 deletions

View File

@@ -2052,6 +2052,30 @@ p_host_type(void) {
return(unify(out,ARG1));
}
static Int
p_same_file(void) {
char *f1 = RepAtom(AtomOfTerm(Deref(ARG1)))->StrOfAE;
char *f2 = RepAtom(AtomOfTerm(Deref(ARG2)))->StrOfAE;
#if HAVE_LSTAT
struct stat buf1, buf2;
if (stat(f1, &buf1) == -1) {
/* file does not exist, but was opened? Return -1 */
return(FALSE);
}
if (stat(f2, &buf2) == -1) {
/* file does not exist, but was opened? Return -1 */
return(FALSE);
}
if (strcmp(f1,f2) == 0) {
printf("Here I go with %s and %s\n", f1, f2);
}
return(buf1.st_ino == buf2.st_ino &&
buf1.st_dev == buf2.st_dev);
#else
return(strcmp(f1,f2) == 0);
#endif
}
/*
* This is responsable for the initialization of all machine dependant
* predicates
@@ -2101,6 +2125,7 @@ InitSysPreds(void)
InitCPred ("$file_age", 2, p_file_age, SafePredFlag|SyncPredFlag);
InitCPred ("$set_fpu_exceptions", 0, p_set_fpu_exceptions, SafePredFlag|SyncPredFlag);
InitCPred ("$host_type", 1, p_host_type, SafePredFlag|SyncPredFlag);
InitCPred ("$same_file", 2, p_same_file, SafePredFlag|SyncPredFlag);
}