[filesystem] Relative Draft Proposal RFC
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 p("/a/b/c"); path base("/a/b"); 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 mine. The full proposal is at http://boostorg.github.io/filesystem/relative_proposal.html A preliminary implementation is available in the feature/relative2 branch of the Boost Filesystem Git repository. See github.com/boostorg/filesystem/tree/feature/relative2 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? Thanks, --Beman
The current version of the Boost proposal is at http://boostorg.github.io/ filesystem/relative_proposal.html Changes include: * Changed the lexical functions from member to non-member, and prefixed names with "lexically_" to disambiguate. For rationale, see http://boostorg.github.io/filesystem/relative_proposal.html#Add-lexical-func... * Added the proximate functions as described in Jamie Allsop's http://github.com/ja11sop/std-filesystem-relative/blob/master/papers/D0011.m... * Cleaned up weakly_canonical standardese. As far as the C++ File System TS is concerned, Jamie and I are in discussions about combining our efforts into a single proposal. I'll give it another day or so to see if any more comments come in, then plan to merge feature/relative2 to develop. --Beman
participants (1)
-
Beman Dawes