[iolib-devel] file-path stuff and handling of trailing /

Stelian Ionescu sionescu at cddr.org
Sun Oct 10 11:42:29 UTC 2010


On Sun, 2010-10-10 at 13:24 +0200, Attila Lendvai wrote:
> >> i repeatedly struggle due to this behavior:
> >> (iolib.pathnames:file-path-directory (iolib.pathnames:file-path
> >> "/tmp/")) => (:ROOT)
> >
> > What's the problem exactly ?
> 
> i list a few cases that doesn't match my expectations when it comes to
> a high level lib dealing with file path parsing and manipulating:
> 
> (file-path-file-name (file-path "/tmp/foo/")) => "foo"
> 
> (file-path-file-type (file-path "/tmp/foo.bar/")) =>"bar"

On *nix and Windows, there's no syntactic difference between paths
representing files and directories(except for a possible final slash),
so this means that the fact that a path represents a directory must be
baked into the application logic: if you know that for your purposes
"/tmp/foo" must be a directory, then calling file-path-file-name on it
is just nonsensical

> (file-path-namestring (file-path "/tmp/foo/")) => "/tmp/foo"
> 
> this last one especially when interfacing with cl:ensure-directories-exist

Ok, I'll fix this because it would be useful that
(string= <path> (file-path-namestring (file-path <path>)))
be always T

-- 
Stelian Ionescu a.k.a. fe[nl]ix
Quidquid latine dictum sit, altum videtur.
http://common-lisp.net/project/iolib
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part
URL: <https://mailman.common-lisp.net/pipermail/iolib-devel/attachments/20101010/d6ae0b17/attachment.sig>


More information about the iolib-devel mailing list