fsAppend
is an absolute path since it starts with /
and you're on a system such as POSIX where paths starting with /
are absolute.
Appending one absolute path to another absolute path doesn't make any sense (to me throwing an exception would be the most natural result actually). What should the result of C:foo.txt
append C:ar.txt
be?
In experimental::fs
the rule was that if the second argument's .native()
started with a directory separator then it was treated as a relative path for append purposes, even though it may be an absolute path in other contexts!
The standardized filesystem clearly distinguishes absolute paths from relative paths, trying to avoid this ambiguity that arises on POSIX systems.
The write-up of the change can be found in P0492R2 US77.
Note that you can use +=
rather than /
for concatenation (should do what you expect), or make the second argument relative before using /
.
Also see this answer for further comparison between experimental
and finalized.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…