existsAnd

  1. bool existsAnd(Path file)
  2. bool existsAnd(Path file)
  3. bool existsAnd(Path file)
    @safe nothrow
    bool
    existsAnd
    (
    alias pred : isSymlink
    )
    (
    const Path file
    )

Return Value

Type: bool

true if file exists and is a symlink.

Examples

Example:

import std.file : remove, symlink, mkdir;
import std.format : format;
import std.stdio : File;

const base = Path(format!"%s_%s"(__FILE__, __LINE__)).baseName;
const Path fname = base ~ "_file";
const Path dname = base ~ "_dir";
const Path symname = base ~ "_symlink";
scope (exit)
    () {
    foreach (f; [fname, dname, symname]) {
        if (exists(f))
            remove(f);
    }
}();

File(fname, "w").write("foo");
mkdir(dname);
symlink(fname, symname);

assert(exists(fname));
assert(existsAnd!isFile(fname));
assert(existsAnd!isDir(dname));
assert(existsAnd!isSymlink(symname));

Meta