This is still the header! Main site

Merging Lisp pathnames

2022/03/12
This is post no. 92 for Kev Quirk's #100DaysToOffload challenge. The point is to write many things, not to write good ones. Please adjust quality expectations accordingly :)

... a very short article today, about Common Lisp and pathnames... a topic which I already wrote about in Common Lisp for shell scripting.

What I did leave out is... a bunch of pathname operations that might be useful. For example, merging pathnames with different components:


CL-USER> (merge-pathnames #P"/some/directory/" #P"file.name")
#P"/some/directory/file.name"
                

... which is, actually, not really a generic pathname join: it takes the directory component out of one pathname and the file name one from another. Weirdly, to combine different directories, we need actual libraries... which seem to be around by default anyway:


CL-USER> (cl-fad:merge-pathnames-as-directory #P"/the/root/" #P"some/other/path/")
#P"/the/root/some/other/path/"
                

... comments welcome, either in email or on the (eventual) Mastodon post on Fosstodon.