<filesystem> Should path::make_preferred collapse directory_separators?
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 11.1k
- Forks
- 1.7k
- Avg merge
- 4d 15h
- Merged PRs (30d)
- 22
Description
I think this deserves an L[E]WG issue. TL;DR, should it be that:
path p("a////b");
p.make_preferred();
assert(p.string() == "a\\\\\\\\b");
or
path p("a////b");
p.make_preferred();
assert(p.string() == "a\\b");
?
The standard for make_preferred says: http://eel.is/c++draft/fs.class.path#fs.path.modifiers-2
Effects: Each directory-separator of the pathname in the generic format is converted to preferred-separator.
with examples showing /s replaced with \s on Windows. Upon closer inspection, however, directory-separator is defined as any number of directory separator characters. From http://eel.is/c++draft/fs.path.generic
directory-separator:
preferred-separator directory-separator(opt)
fallback-separator fallback-separator(opt)preferred-separator:
operating system dependent directory separator characterfallback-separator:
/ if preferred-separator is not /
The microsoft/STL implements this by replacing all /s with \s in the path:
(I probably wrote this code so you know who to blame 😅)
as does Boost:
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the C++ standard clauses for path::make_preferred and the directory-separator definition, then inspect stl/inc/filesystem at the referenced line and compare Boost's implementation. Determine whether repeated separators should be preserved or collapsed and whether an LWG issue is needed; done means the expected behavior is resolved and documented.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- operating-systems
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100