I'm not new to Lisp but new to CL and a bit confused by the file and directory path handling. What I need: A completely cross-platform way to deal with file and directory paths that can be specified in URLs and stored in a database (preferably as text).
Current approach: Store a file path as a file URL using QURI
, strictly with / Unix-style paths and serializable as URL strings. When I need local file access, these URL paths are translated to the local OS-specific file path. So I use UIOP:parse-unix-namestring
to convert to a slash path and QURI
to construct URLs.
Problem: The UIOP
docs say that unix-namestring
is not suitable for general platform-specific paths, and I need to convert the unix pathname to a string to store it in the DB. Moreover, most of the paths are going to be relative, but some of them could be absolute for external assets, and the UIOP
docs also say that parse-unix-namestring
is not suitable for absolute paths.
Questions: Every tutorial I've found recommends UIOP
. But what's the right way of storing paths to folders and files in a cross-platform way in a database then? Am I about to do something horrible? Should I get rid of the idea of using URLs to store asset locations? It has the advantage to generalize nicely to other types of locations such as files on ftp and http servers. Am I safe if I make sure all paths are relative and proceed with using UIOP? Or, is there a better way to do this?
It's really important that this works on all kinds of (modern) file systems, with network volumes, etc.