The OpenD Programming Language

filenameCmp

Compares file names and returns

Individual characters are compared using filenameCharCmp!cs, where cs is an optional template parameter determining whether the comparison is case sensitive or not.

Treatment of invalid UTF encodings is implementation defined.

int
filenameCmp
(
Range1 filename1
,
Range2 filename2
)

Parameters

cs

case sensitivity

filename1 Range1

range for first file name

filename2 Range2

range for second file name

Return Value

Type: int

< 0 if filename1 < filename2, 0 if filename1 == filename2 and > 0 if filename1 > filename2.

Examples

assert(filenameCmp("abc", "abc") == 0);
assert(filenameCmp("abc", "abd") < 0);
assert(filenameCmp("abc", "abb") > 0);
assert(filenameCmp("abc", "abcd") < 0);
assert(filenameCmp("abcd", "abc") > 0);

version (linux)
{
    // Same as calling filenameCmp!(CaseSensitive.yes)(filename1, filename2)
    assert(filenameCmp("Abc", "abc") < 0);
    assert(filenameCmp("abc", "Abc") > 0);
}
version (Windows)
{
    // Same as calling filenameCmp!(CaseSensitive.no)(filename1, filename2)
    assert(filenameCmp("Abc", "abc") == 0);
    assert(filenameCmp("abc", "Abc") == 0);
    assert(filenameCmp("Abc", "abD") < 0);
    assert(filenameCmp("abc", "AbB") > 0);
}

See Also

Meta