[Issue 10348] New: isRooted is either wrong or poorly specified

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Jun 12 18:19:16 PDT 2013


http://d.puremagic.com/issues/show_bug.cgi?id=10348

           Summary: isRooted is either wrong or poorly specified
           Product: D
           Version: D2
          Platform: All
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody at puremagic.com
        ReportedBy: andrej.mitrovich at gmail.com


--- Comment #0 from Andrej Mitrovic <andrej.mitrovich at gmail.com> 2013-06-12 18:19:15 PDT ---
-----
import std.path;

void main()
{
    assert(!isAbsolute(r"\"));  // ok
    assert(!isRooted(r"\"));  // fails, path is rooted
}
-----

How can a non-absolute path be rooted? It doesn't make sense to me that r"\"
itself is rooted (where is it rooted? which drive or network drive?). It's not
a valid path on Windows.

Another example:

-----
import std.path;

void main()
{
    assert(!isAbsolute(r"\"));  // ok
    assert(absolutePath(r"\") != r"\");  // fails, it returned r"\"
}
-----

So if r"\" is not an absolute path, how can the absolute path of r"\" be r"\"
when it's not absolute?

The docs for isRooted state:

"Determines whether a path starts at a root directory."

So in that case absolutePath() should have no problem creating an absolute path
of such a rooted path. But you can't create an absolute path out of r"\". r"\"
is not rooted anywhere. I think isRooted should have these tests:

assert (!isRooted(`\`));  // changed
assert (!isRooted(`\foo`));  // changed
assert (isRooted(`d:\foo`));
assert (isRooted(`\\foo\bar`));
assert (!isRooted("foo"));
assert (!isRooted("d:foo"));

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list