CL:DIRECTORY no longer errors on files containing asterisk characters

Fix non-restartable error on entries which are WILD-PATHNAME-P by
changing the method signature of SYS:FILE-DIRECTORY-P to:

       pathspec &key (wild-error-p t)

Have CL:DIRECTORY use (SYS:FILE-DIRECTORY-P PATHSPEC :wild-error-p
nil).

TODO: The #\* character should be treated as a literal #\* in calls
PROBE-{FILE,DIRECTORY}, but we currently have no distinct
representations. PATHNAME components which have wildcards need to have
different representations of wildcard characters vs. their namestring
representation.  SBCL does a reasonable job here, although it will
mean revisiting the implementation in Pathname.java, so it is
advisable to take the time to make a reasonable test suite.

<> :addresses <http://abcl.org/trac/ticket/391> .
parent c5e3f6bf
......@@ -152,6 +152,7 @@ public final class Keyword
VALUE = internKeyword("VALUE"),
VERSION = internKeyword("VERSION"),
WILD = internKeyword("WILD"),
WILD_ERROR_P = internKeyword("WILD-ERROR-P"),
WILD_INFERIORS = internKeyword("WILD-INFERIORS"),
WINDOWS = internKeyword("WINDOWS"),
X86 = internKeyword("X86"),
......
......@@ -137,7 +137,7 @@ error to its caller."
(when
(or
(and
(file-directory-p entry)
(file-directory-p entry :wild-error-p nil)
(pathname-match-p (file-namestring (pathname-as-file entry))
(file-namestring pathname)))
(pathname-match-p (or (file-namestring entry) "")
......
......@@ -95,21 +95,41 @@ public final class probe_file
public static final Primitive FILE_DIRECTORY_P
= new pf_file_directory_p();
@DocString(name="file-directory-p",
args="pathspec",
args="pathspec &key (wild-error-p t)",
returns="generalized-boolean")
private static final class pf_file_directory_p extends Primitive {
pf_file_directory_p() {
super("file-directory-p", PACKAGE_EXT, true);
}
private LispObject isDirectory(Pathname p) {
File file = p.getFile();
return file.isDirectory() ? T : NIL;
}
@Override
public LispObject execute(LispObject arg) // XXX Should this merge with defaults?
{
Pathname pathname = coerceToPathname(arg);
if (pathname.isWild())
if (pathname.isWild()) {
error(new FileError("Bad place for a wild pathname.", pathname));
File file = pathname.getFile();
return file.isDirectory() ? T : NIL;
}
return isDirectory(pathname);
}
@Override
public LispObject execute(LispObject arg, LispObject wildErrorPKeyword, LispObject wildErrorP)
{
if (!(wildErrorPKeyword.equals(Keyword.WILD_ERROR_P))) {
type_error(wildErrorPKeyword, Keyword.WILD_ERROR_P);
}
Pathname pathname = coerceToPathname(arg);
if (wildErrorP != NIL) {
if (pathname.isWild()) {
error(new FileError("Bad place for a wild pathname.", pathname));
}
}
return isDirectory(pathname);
}
};
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment