View source code
Display the source code in std/path.d from which this page was generated on
github.
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.
Page wiki
View or edit the community-maintained wiki page associated with this page.
Function std.path.driveName
Get the drive portion of a path
.
Prototype
auto driveName(R)( R path ) if (isRandomAccessRange!R && hasSlicing!R && hasLength!R && isSomeChar!(ElementType!R) || is(StringTypeOf!R));
Parameters
Name | Description |
---|---|
path | string or range of characters |
Returns
A slice of path
that is the drive, or an empty range if the drive
is not specified. In the case of UNC paths, the network share
is returned.
Always returns an empty range on POSIX.
Examples
version (Windows) { assert (driveName(d:\file
) == "d:"); assert (driveName(\\server\share\file
) ==\\server\share
); assert (driveName(dir\file
).empty); }
Authors
Lars Tandle Kyllingstad, Walter Bright, Grzegorz Adam Hankiewicz, Thomas Kühne, Andrei Alexandrescu