View source code
Display the source code in std/file.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.file.isSymlink
Returns whether the given file is a symbolic link.
bool isSymlink(R)
(
R name
) @property
if (isInputRange!R && !isInfinite!R && isSomeChar!(ElementEncodingType!R) && !isConvertibleToString!R);
bool isSymlink(R)
(
auto ref R name
) @property
if (isConvertibleToString!R);
On Windows, returns true
when the file is either a symbolic link or a
junction point.
Parameters
Name | Description |
---|---|
name | The path to the file. |
Returns
true if name is a symbolic link
Throws
FileException
if the given file does not exist.
Example
import std .exception : assertThrown;
auto source = deleteme ~ "source";
auto target = deleteme ~ "target";
assert(!source .exists);
assertThrown!FileException(source .isSymlink);
// symlinking isn't available on Windows
version(Posix)
{
scope(exit) source .remove, target .remove;
target .write("target");
target .symlink(source);
writeln(source .readText); // "target"
assert(source .isSymlink);
assert(source .getLinkAttributes .attrIsSymlink);
}
Authors
License
Copyright © 1999-2022 by the D Language Foundation | Page generated by ddox.