View source code
Display the source code in std/path.d from which this
page was generated on github.
Report a bug
If you spot a problem with this page, click here to create a
Bugzilla issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page.
Requires a signed-in GitHub account. This works well for small changes.
If you'd like to make larger changes you may want to consider using
local clone.
Function std.path.filenameCharCmp
Compares filename characters.
int filenameCharCmp(CaseSensitive cs = CaseSensitive .osDefault)
(
dchar a,
dchar b
) pure nothrow @safe;
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
.
On Windows, the backslash and slash characters (
and \
)
are considered equal.
/
Parameters
Name | Description |
---|---|
cs | Case-sensitivity of the comparison. |
a | A filename character. |
b | A filename character. |
Returns
Example
writeln(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)
writeln(filenameCharCmp('a', 'A')); // 0
assert(filenameCharCmp('a', 'B') < 0);
assert(filenameCharCmp('A', 'b') < 0);
}
Authors
Lars Tandle Kyllingstad, Walter Bright, Grzegorz Adam Hankiewicz, Thomas Kühne, Andrei Alexandrescu
License
Copyright © 1999-2024 by the D Language Foundation | Page generated by ddox.