pathlib

Members

Aliases

Path
alias Path = WindowsPath

Set the default path depending on the current platform.

Classes

PathException
class PathException

Exception that will be thrown when any path operations fail.

Functions

appendFile
void appendFile(in Path p, in void[] buffer)
copyFileTo
void copyFileTo(in Path src, in Path dest)

Copy a file to some destination. If the destination exists and is a file, it is overwritten. If it is an existing directory, the actual destination will be ($D dest ~ src.name). Behaves like std.file.copy except that dest does not have to be a file.

copyTo
void copyTo(in Path src, in Path dest)

Copy a file or directory to a target file or directory.

currentExePath
Path currentExePath()

The path to the current executable.

cwd
Path cwd()

The absolute path to the current working directory with symlinks and friends resolved.

drive
auto drive(auto ref in PathType p)

The drive of the path p. Note: Non-Windows platforms have no concept of "drives".

exists
bool exists(in Path p)

Whether the path exists or not. It does not matter whether it is a file or not.

extension
auto extension(auto ref in PathType p)

The extension of the path including the leading dot.

extensions
auto extensions(auto ref in PathType p)

All extensions of the path.

fullExtension
auto fullExtension(auto ref in PathType p)

The full extension of the path.

glob
auto glob(auto ref in Path p, PatternType pattern, SpanMode spanMode = SpanMode.shallow)

Generate an input range of Paths that match the given pattern.

isAbsolute
auto isAbsolute(auto ref in PathType p)

Whether the path is absolute.

isDir
bool isDir(in Path p)

Whether the path is an existing directory.

isDot
bool isDot(auto ref in StringType str)

Whether str can be represented by ".".

isDot
auto isDot(auto ref in PathType p)

Whether the path is either "" or ".".

isFile
bool isFile(in Path p)

Whether the path is an existing file.

isSymlink
bool isSymlink(in Path p)

Whether the given path p points to a symbolic link (or junction point in Windows).

match
auto match(auto ref in PathType p, Pattern pattern)

Whether the given path matches the given glob-style pattern

mkdir
void mkdir(in Path p, bool parents = true)
name
auto name(auto ref in PathType p)

The name of the path without any of its parents.

normalizedData
auto normalizedData(auto ref in PathType p)

Remove duplicate directory separators and stand-alone dots, on a textual basis. Does not resolve ".."s in paths, since this would be wrong when dealing with symlinks. Given the symlink "/foo" pointing to "/what/ever", the path "/foo/../baz.exe" would 'physically' be "/what/baz.exe". If "/foo" was no symlink, the actual path would be "/baz.exe".

parents
auto parents(auto ref in PathType p)

/foo/bar/baz/hurr.durr => { Path("/foo/bar/baz"), Path("/foo/bar"), Path("/foo"), Path("/") }

parts
auto parts(auto ref in PathType p)
posixData
auto posixData(auto ref in PathType p)
readFile
auto readFile(in Path p)
relativeTo
auto relativeTo(auto ref in PathType p, in auto ref PathType parent)

Create a path from p that is relative to parent.

remove
void remove(in Path p, bool recursive = true)

Remove path from filesystem. Similar to unix rm. If the path is a dir, will reecursively remove all subdirs by default.

root
auto root(auto ref in PathType p)
stem
auto stem(auto ref in PathType p)

The name of the path without its extension.

windowsData
auto windowsData(auto ref in PathType p)
writeFile
void writeFile(in Path p, const void[] buffer)

Mixin templates

PathCommon
mixin template PathCommon(TheStringType, alias theSeparator, alias theCaseSensitivity)

Structs

PosixPath
struct PosixPath
ScopedChdir
struct ScopedChdir

Helper struct to change the directory for the current scope.

WindowsPath
struct WindowsPath

Meta

Authors

Manuzor

ToDo: - Path().open(...)