[Issue 12114] New: buildNormalizedPath shouldn't normalize current path to empty string
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sat Feb 8 15:37:05 PST 2014
https://d.puremagic.com/issues/show_bug.cgi?id=12114
Summary: buildNormalizedPath shouldn't normalize current path
to empty string
Product: D
Version: unspecified
Platform: All
OS/Version: All
Status: NEW
Severity: normal
Priority: P2
Component: Phobos
AssignedTo: nobody at puremagic.com
ReportedBy: cbkbbejeap at mailinator.com
--- Comment #0 from Nick Sabalausky <cbkbbejeap at mailinator.com> 2014-02-08 15:37:03 PST ---
Currently, buildNormalizedPath("."), buildNormalizedPath("foo/.."), etc all
return empty string.
While buildNormalizedPath should indeed remove superfluous uses of "." within a
path, paths that ultimately simplify to the current directory should result in
"." not empty string (much like how buildNormalizedPath("..") returns "..").
This is for two reasons:
1. Other functions in std.path (rootName, driveName, extension) already use ""
to mean "does not exist" which is very distinct from "current directory". When
"current directory" is passed into buildNormalizedPath, the result should not
be confusable with "does not exist".
2. To reduce the chances of accidental bugs like this:
auto from = buildNormalizedPath(...);
executeShell("cp "~from~ " target"); // Oops, the "from" argument might be
missing!
Note that an empty input (such as buildNormalizedPath(),
buildNormalizedPath(""), or buildNormalizedPath("", "")) should still result in
an empty string (as it does now) so that "does not exist" cannot get
accidentally converted to "current directory":
auto x = rootName("some/relative/path");
...
buildNormalizedPath(x); // Oops! A missing path got "normalized" to current
directory.
--
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list