isSymlink

Returns whether the given file is a symbolic link.

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

  1. bool isSymlink [@property getter]
  2. bool isSymlink [@property getter]
    @property
    bool
    isSymlink
    (
    R
    )
    (
    auto ref R name
    )

Parameters

name R

The path to the file.

Return Value

Type: bool

true if name is a symbolic link

Throws

FileException if the given file does not exist.

Examples

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);
    assert(source.readText == "target");
    assert(source.isSymlink);
    assert(source.getLinkAttributes.attrIsSymlink);
}

Meta