(no subject) 
Author Message
 (no subject)

%I'm trying to write a simple file existence handler, the samples
from the Quintus reference pages have not been quite what I needed.  
In fact, I found some major problems with the example from the
Quintus reference pages (G.19-5 for my version -Errors and Exceptions)  
Seems like it should be simple.  I found an interesting result, however.  

Here the general idea:
        1) if you can 'see' the file, it must exist
        2) else, it doesn't exist

This works great except that if you delete a file during the run and then check
for it's existence, it still says it exists!  Ahi!  Any ideas why?  It appears
that Quintus loads the directory into memory once only.

%This is the code and a sample run of program in Quintus environment:

isfile(F,yes):-
   see(F),
   !.
isfile(_,no).

%------ load isfile.pl
| ?- [isfile].
% compiling file /tools/claire/claire8/addons/transactions/isfile.pl
% isfile.pl compiled in module user, 0.034 sec 340 bytes

yes
%--- try it with a known existing file

| ?- isfile('junk.stuff',X).

X = yes

%--- try it with a non-existent file
| ?- isfile(xxx,X).
! Existence error in argument 1 of see/1
! file '/tools/claire/claire8/addons/transactions/xxx' does not exist
! Unix error : No such file or directory
! goal:  see(xxx)

%--- use built-in to turn off file errors.
| ?- nofileerrors.

yes

%--- try checking for non-existent file again
| ?- isfile(xxx,X).

X = no
%--- everything works so far!

%--- remove existing file
| ?- unix(system('rm junk.stuff')).

yes

%--- check to see file is gone
| ?- isfile('junk.stuff',X).

X = yes

%--- !!!!! what? why does this happen?

%note: checking for previously non-existing file give correct response
| ?- isfile(xxxx,X).

X = no



Mon, 25 May 1998 03:00:00 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. posting subject conventsions

2. no subject given

3. Subject: Re: J2 surprise

4. Subject: Re: J2 control word design question

5. no subject given

6. no subject given

7. no subject given

8. no subject given

9. no subject given

10. no subject given

11. no subject given

12. no subject given

 

 
Powered by phpBB® Forum Software