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.filenameCmp
Compares file names and returns
int filenameCmp(CaseSensitive cs = CaseSensitive .osDefault, Range1, Range2)
(
Range1 filename1,
Range2 filename2
)
if (isSomeFiniteCharInputRange!Range1 && !isConvertibleToString!Range1 && isSomeFiniteCharInputRange!Range2 && !isConvertibleToString!Range2);
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.
Parameters
Name | Description |
---|---|
cs | case sensitivity |
filename1 | range for first file name |
filename2 | range for second file name |
Returns
< 0
if filename1 < filename2
,
0
if filename1 == filename2
and
> 0
if filename1 > filename2
.
See Also
Example
writeln(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)
writeln(filenameCmp("Abc", "abc")); // 0
writeln(filenameCmp("abc", "Abc")); // 0
assert(filenameCmp("Abc", "abD") < 0);
assert(filenameCmp("abc", "AbB") > 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.