Examples
Doesn't like http://
URLs:
?- uri_file_name('http://www.example.com/toppy',FileName). false.
Likes local file://
URLS:
?- uri_file_name('file:///toppy',FileName). FileName = '/toppy'.
Sadly, doesn't like "remote file URLs" either (but really should):
?- uri_file_name('file://vms.host.edu/disk$user/my/notes/note12345.txt',FileName). false.
However:
?- uri_file_name('file://localhost/disk$user/my/notes/note12345.txt',FileName). FileName = '/disk$user/my/notes/note12345.txt'.
This looks ok too:
?- uri_file_name('file://localhost/disk$user/my/notes/',FileName). FileName = '/disk$user/my/notes/'.
Working URI-wards
Absolute filename:
?- uri_file_name(URI,'/usr/lib/shadow.so'). URI = 'file:///usr/lib/shadow.so'.
For a relative filename, the predicate prepends the current working directory of swipl. See working_directory/2.
?- working_directory(X,X). X = '/home/paquette/'. ?- uri_file_name(X,'foo/bar'). X = 'file:///home/paquette/foo/bar'.
RFCs
In particular, section 3.10 of RFC 1738:
3.10 FILES The file URL scheme is used to designate files accessible on a particular host computer. This scheme, unlike most other URL schemes, does not designate a resource that is universally accessible over the Internet. A file URL takes the form: file://<host>/<path> where <host> is the fully qualified domain name of the system on which the <path> is accessible, and <path> is a hierarchical directory path of the form <directory>/<directory>/.../<name>. For example, a VMS file DISK$USER:[MY.NOTES]NOTE123456.TXT might become <URL:file://vms.host.edu/disk$user/my/notes/note12345.txt> As a special case, <host> can be the string "localhost" or the empty string; this is interpreted as `the machine from which the URL is being interpreted'. The file URL scheme is unusual in that it does not specify an Internet protocol or access method for such files; as such, its utility in network protocols between hosts is limited.