The OpenD Programming Language

attrIsSymlink

Returns whether the given file attributes are for a symbolic link.

On Windows, return true when the file is either a symbolic link or a junction point.

@safe pure nothrow @nogc
bool
attrIsSymlink
()

Parameters

attributes uint

The file attributes.

Return Value

Type: bool

true if attributes are for a symbolic link

Examples

core.sys.posix.unistd.symlink("/etc/fonts/fonts.conf", "/tmp/alink");

assert(!getAttributes("/tmp/alink").isSymlink);
assert(getLinkAttributes("/tmp/alink").isSymlink);
import std.exception : assertThrown;

auto source = deleteme ~ "source";
auto target = deleteme ~ "target";

assert(!source.exists);
assertThrown!FileException(source.getLinkAttributes.attrIsSymlink);

// symlinking isn't available on Windows
version (Posix)
{
    scope(exit) source.remove, target.remove;

    target.write("target");
    target.symlink(source);
    assert(source.readText == "target");
    assert(source.isSymlink);
    assert(source.getLinkAttributes.attrIsSymlink);
}

Meta