The OpenD Programming Language

filenameCharCmp

Compares filename characters.

This function can perform a case-sensitive or a case-insensitive comparison. This is controlled through the cs template parameter which, if not specified, is given by CaseSensitive.osDefault.

On Windows, the backslash and slash characters (`\` and `/`) are considered equal.

@safe pure nothrow
int
filenameCharCmp
(
dchar a
,
dchar b
)

Parameters

cs

Case-sensitivity of the comparison.

a dchar

A filename character.

b dchar

A filename character.

Return Value

Type: int

< 0 if a < b, 0 if a == b, and > 0 if a > b.

Examples

assert(filenameCharCmp('a', 'a') == 0);
assert(filenameCharCmp('a', 'b') < 0);
assert(filenameCharCmp('b', 'a') > 0);

version (linux)
{
    // Same as calling filenameCharCmp!(CaseSensitive.yes)(a, b)
    assert(filenameCharCmp('A', 'a') < 0);
    assert(filenameCharCmp('a', 'A') > 0);
}
version (Windows)
{
    // Same as calling filenameCharCmp!(CaseSensitive.no)(a, b)
    assert(filenameCharCmp('a', 'A') == 0);
    assert(filenameCharCmp('a', 'B') < 0);
    assert(filenameCharCmp('A', 'b') < 0);
}

Meta