Search code examples
common-lispfilenameswildcardclisppathname

pathnames in Common Lisp, filenames with wildcards in them


The characters * and ? are used as wildcards in pathnames. How does one refer to a filename that has ? as one of its actual characters? For example: [18]> (wild-pathname-p #p"foo") NIL [19]> (wild-pathname-p #p"foo?") T So referring to the filename "foo?" cannot be done this way. I tried to escape the ? with a backslash, but that didn't work. I tried going unicode by using \u3f or \u003f, but that didn't work.

How do I refer to a file that contains a wildcard as part of its name: How to probe it, open it, etc.?


Solution

  • It depends on the implementation, but for some, a backslash does in fact work. But because namestrings are strings, to get a string with a backslash in it, you have to escape the backslash with another backslash. So, for example, "foo?" is escaped as "foo\\?", not "foo\?".

    Last time I checked, in CLISP, there is no way to refer to files with wildcards in the names. My solution to that is to avoid CLISP.