doublyBackslashed

Returns the supplied string with any backslashes doubled. This is to make paths on Windows display properly.

Merely returns the given string on Posix and other non-Windows platforms.

doublyBackslashed
(
const string path
)

Parameters

path string

The original path string with only single backslashes.

Return Value

Type: auto

The passed path but doubly backslashed.

Examples

string path = r"c:\Windows\system32";
assert(path.doublyBackslashed == r"c:\\Windows\\system32");
{
    enum path = r"c:\windows\system32";
    enum expected = r"c:\\windows\\system32";
    immutable actual = path.doublyBackslashed;
    assert((actual == expected), actual);
}
{
    enum path = r"c:\Users\blerp\AppData\Local\kameloso\server\irc.chat.twitch.tv";
    enum expected = r"c:\\Users\\blerp\\AppData\\Local\\kameloso\\server\\irc.chat.twitch.tv";
    immutable actual = path.doublyBackslashed;
    assert((actual == expected), actual);
}
{
    enum path = r"c:\\windows\\system32";
    enum expected = r"c:\\windows\\system32";
    immutable actual = path.doublyBackslashed;
    assert((actual == expected), actual);
}