makeRelative

Jon Fairbairn jon.fairbairn at cl.cam.ac.uk
Wed Sep 26 16:30:50 CEST 2012


I have an application where I want to use relative paths in
symlinks (so that rsyncing to a different machine with a
different root directory produces something with the same
effect).

So I want

makeRelative "/var/www/this_server/foo/bar/" "/var/www/this_server/bob"

to return "../../bob" (which would then be used to create a
symlink) so that if I copy the tree below /var/www/this_server
to /var/www/that_server (perhaps on a different machine, but
copying the symlinks without rewriting them), the symlinks point
to the same files.

On posix at least, this would permit isRelative (makeRelative a
b) always to be True, which is a pleasant property for it to
have.

Is there any reason that System.FilePath.Posix.makeRelative should not
do this? I don’t know enough about non-posix filesystems to know
whether it even makes sense elsewhere.

-- 
Jón Fairbairn                                 Jon.Fairbairn at cl.cam.ac.uk





More information about the Libraries mailing list