Subject: [boost] [filesystem] Relative Draft Proposal RFC
From: Beman Dawes (bdawes_at_[hidden])
Date: 2015-08-19 10:55:50
There have been requests for a Filesystem library relative function for at
least ten years.
The requested functionality seems simple - given two paths with a common
prefix, return the non-common suffix portion of one of the paths such that
it is relative to the other path.
In terms of the Filesystem library,
path rel = relative(p, base); // the requested function
cout << rel << endl; // outputs "c"
assert(absolute(rel, base) == p);
If that was all there was to it, the Filesystem library would have had a
relative function years ago.
Critical issues: Clashing requirements, symlinks, directory placeholders
(dot, dot-dot), user-expectations, corner cases.
A paper by Jamie Allsop, Additions to Filesystem supporting Relative Paths,
is what broke my mental logjam. Much of [my proposal] is based directly on
Jamie's analysis and proposal. The weakly_canonical function and aspects of
the semantic specifications are my contributions. Mistakes, of course, are
The full proposal is at
A preliminary implementation is available in the feature/relative2 branch
of the Boost Filesystem Git repository. See
The overall plan is to get feedback from boost developers, then merge to
develop for boost 1.60, then propose to the C++ committee for addition to
the Filesystem TS.
Comments welcome. If you are one of the many people who have requested
"relative" functionality, does this proposal meet your needs? If not, why?
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk