Greetings! "Page, Bill" <[EMAIL PROTECTED]> writes:
> Camm, > > On Wednesday, September 06, 2006 1:50 PM you wrote: > > > > Bill Page writes: > > ... > > > > > > > > In src/interp/nlib.lisp.pamphlet: > > > > > > > > ---------- > > > > > > > > ;; ($ERASE filearg) -> 0 if succeeds else 1 > > > > (defun $erase (&rest filearg) > > > > (setq filearg (make-full-namestring filearg)) > > > > - (if (probe-file filearg) > > > > + (if (directory (truename filearg)) > > > > #+:CCL (delete-file filearg) > > > > #+:AKCL > > > > (if (library-file filearg) > > > > (delete-directory filearg) > > > > (delete-file filearg)) > > > > 1)) > > > > > > > > ---------- > > > > > > > ... > > > However I remain a little uncertain if 'directory' is really > > > the proper way to check for the existence of a file or > > > directory in common lisp? > > > > > > > 1) I think you want (null (pathname-name (truename filearg))) > > > > 2) or (and (directory filearg) (not (probe-file filearg))) > > > > Sorry, I still feel a little "dense" about this. Could you take > a minute to translate these two expressions for me? I want > > (if (... filearg) > ) > > to be true if filearg is either a file *or* a directory. My apologies -- I thought you just wanted a directory. So both of the above are wrong. truename is required to return an error if the path does not exist. So you might not want this. I think we might still be deviating from the spec on directory a bit. Even though we pass all the ansi tests. At the moment, the best I can think of is (or (probe-file filearg) (= 1 (length (directory filearg)))) We can change this if it is deemed insufficient, and/or add a si::stat function. The pathnames returned by truename or directory, etc., are structures with components: device directory name type The second is a list of components, which can include keywords :current, :absolute, etc. It can also be nil, which gives the default, i.e. current working dir. Pathnames corresponding to directories have nil in the last two slots, and have corresponding namestrings ending in "/". Unfortunately, as you state, directory at present has a certain globbin/pattern matching behavior which is not so useful in this context. Again, we can likely change this if needed. Take care, > > I suspect that 2) requires that it be a directory and not a file > since 'probe-file' is now interpreted as specifically as testing > for a *file*. So maybe that one is not right? > > I am also worried about the "wild-card" properties of 'directory' > which is not something I really want. > > But I don't know the semantics of 1) at all, and having > consulted the lisp docs as deeply as possible, I am still > not sure. What exactly does expression 1) do on GCL? > > Regards, > Bill Page. > > > -- Camm Maguire [EMAIL PROTECTED] ========================================================================== "The earth is but one country, and mankind its citizens." -- Baha'u'llah _______________________________________________ Axiom-developer mailing list [email protected] http://lists.nongnu.org/mailman/listinfo/axiom-developer
