(setf (logical-pathname-translations "home")
((#p";**;*.*" #p"/home/vlz/")))
This gives me
* (translate-logical-pathname #p"home:odbc.log")
#p"/home/vlz/odbc.log"
* (probe-file (translate-logical-pathname #p"home:odbc.log"))
#p"/home/vlz/odbc.log"
Is it possible to deal that way with files which names contains _
(underscore) ? I see
* (translate-logical-pathname #p"home:odbc_.log")
#p"home:odbc_.log"
And PROBE-FILE returns NIL for that. Also I'd like to understand
better what happens. Don't you mind to point me to proper document or
reference ?
--
Vladimir Zolotykh
Logical pathnames are intended as system-independent pathnames that you
map to real pathnames in a particular system. It is a unidirectional
mapping. Note that there is no way to get from a physical pathname to a
logical pathname in the language. Using this strong hint, you should
realize that there is no intention in the language to be able to create a
logical pathname for all physical pathname.
Basically, you enumerate the files you want to exist for your application
using logical pathnames, and then you arrange for this to be true in any
given physical file system.
If you want to refer to existing filenames on the system over which your
application has no (naming) control, use physical pathnames. That is
what they are for.
///
--
In a fight against something, the fight has value, victory has none.
In a fight for something, the fight is a loss, victory merely relief.
Post with compassion: http://home.chello.no/~xyzzy/kitten.jpg
> Suppose I have logical host HOME
>
> (setf (logical-pathname-translations "home")
> ((#p";**;*.*" #p"/home/vlz/")))
I don't understand this translation. logical pathnames starting with ";"
are relative pathnames. I wouldn't expect any such pathnames to ever
be translated, so I'm surprised this works at all.
> This gives me
^^^^^^^^^^^^^
This phrase is meaningless absent an implementation.
CL has no reference implementation.
And you should never assume that what one implementation gives you is
likely to "look like" what another implementation does. The pathname
system exists to paper over numerous differences between implementation
details.
>
> * (translate-logical-pathname #p"home:odbc.log")
> #p"/home/vlz/odbc.log"
If you removed the leading ";" in the translations above,
I'd believe this better. As it is, I think you're getting this result
accidentally.
> * (probe-file (translate-logical-pathname #p"home:odbc.log"))
> #p"/home/vlz/odbc.log"
>
> Is it possible to deal that way with files which names contains _
> (underscore) ? I see
>
> * (translate-logical-pathname #p"home:odbc_.log")
> #p"home:odbc_.log"
>
> And PROBE-FILE returns NIL for that. Also I'd like to understand
> better what happens. Don't you mind to point me to proper document or
> reference ?
Did you read the spec on this? It's a really lousily written chapter,
I admit, but it does have _some_ answers. Hyphens are allowed in
logical pathnames, but underscores are not. It would be within the right
of an implementation to simply signal an error.
See CLHS 19.3.1 Syntax of Logical Pathname Namestrings
The answer to your question, though, is that you are misunderstanding
the purpose of logical pathnames ... they do _not_ exist for the
purpose of handling all files. They exist for the purpose of portable
system-building to force you into using very narrowly chosen names to
maximize your chances of portability across operating systems. The
design is intended to force you into using better names, not to invite
you to falsely pretend that that the intersection of available
characters across all file system types everywhere is somehow broader
than you wish it were. It therefore makes more sense to ask that
hyphen be removed or that the total number of characters allowed in
names be restricted than it does to broaden things... But I hope
you'll not ask for that. It's hard enough working with the set of
characters we have now. :-)
Here is the workaround for my little problem:
(merge-pathnames "foo_.gif" (translate-logical-pathname "webtools:images;"))
where WEBTOOLS host defined as
(setf (logical-pathname-translations "webtools")
'(("**;*.*" #p"home:lisp/webtools/*.*")))
Fortunately, the 'strange' files located in single directory.
Using Lisp for Linux (Slackware 8.0)
(Sorry for not mentioning that earlier)
--
Vladimir Zolotykh
> Thank you Erik and Kent.
>
> Here is the workaround for my little problem:
>
> (merge-pathnames "foo_.gif" (translate-logical-pathname "webtools:images;"))
If you are using logical pathnames mostly as a way to symbolically
reference certain locations in your Unix filesystem, _and_ if you are
only working on CMU CL (or maybe SBCL(?)), then you can use CMU CL's
concept of search-lists, to do this:
(setf (ext:search-list "webtools:") '("home:lisp/webtools/"
;; Possibly other fallback
;; directories here
))
Now you can simply refer to foo_.gif via #p"webtools:images/foo_.gif",
and it will be found. Furthermore, CMU CL only resolves those
pathnames at the time they are used, so that you can e.g. change the
definition of the search-list afterwards, and have it take effect.
See the CMU CL User Manual for details on search-lists.
> where WEBTOOLS host defined as
>
> (setf (logical-pathname-translations "webtools")
> '(("**;*.*" #p"home:lisp/webtools/*.*")))
This ^^^^^^^^^ tells me you are using CMU CL search-lists
already, so this might be a useful solution for you...
Regs, Pierre.
--
Pierre R. Mai <pm...@acm.org> http://www.pmsf.de/pmai/
The most likely way for the world to be destroyed, most experts agree,
is by accident. That's where we come in; we're computer professionals.
We cause accidents. -- Nathaniel Borenstein