Path

Main struct to work with paths.

Constructors

this
this(string path)

Main constructor to build new Path from string

this
this(string[] segments)

Constructor that allows to build path from segments * Params: * segments = array of segments to build path from

Members

Functions

appendFile
void appendFile(void[] buffer)

Append data to file as is

baseName
string baseName()

Returns base name of current path

chdir
void chdir()

Change current working directory to this.

copyFileTo
void copyFileTo(Path dest, bool rewrite)

Copy single file to destination. If destination does not exists, then file will be copied exactly to that path. If destination already exists and it is directory, then method will try to copy file inside that directory with same name. If destination already exists and it is file, then depending on rewrite param file will be owerwritten or PathException will be thrown.

copyTo
void copyTo(Path dest)
void copyTo(string dest)

Copy file or directory to destination If source is a file, then copyFileTo will be use to copy it. If source is a directory, then more complex logic will be applied: - if dest already exists and it is not dir, then exception will be raised. - if dest already exists and it is dir, then source dir will be copied inseide that dir with it's name - if dest does not exists, then current directory will be copied to dest path.

exists
bool exists()

Check if path exists

expandTilde
Path expandTilde()

Expand tilde (~) in current path.

extension
string extension()

Returns extension for current path

getSize
ulong getSize()

Return size of file specified by path

isAbsolute
bool isAbsolute()

Check if path is absolute

isDir
bool isDir()

Determine if path is directory.

isFile
bool isFile()

Determine if path is file.

isRooted
bool isRooted()

Check if path starts at root directory (or drive letter)

isSymlink
bool isSymlink()

Determine if path is symlink

isValid
bool isValid()

Check if path is valid.

join
Path join(string[] segments)
Path join(Path[] segments)

Join multiple path segments and return single path.

mkdir
void mkdir(bool recursive)

Create directory by this path

normalize
Path normalize()

Normalize path.

openFile
std.stdio.File openFile(string openMode)

Open file and return std.stdio.File struct with opened file

parent
Path parent()

determine parent path of this path

readFile
auto readFile(size_t upTo)

Read entire contents of file name and returns it as an untyped array. If the file size is larger than upTo, only upTo bytes are _read.

readLink
Path readLink()

Resolve link and return real path. Available only for posix systems. If path is not symlink, then return it unchanged

relativeTo
Path relativeTo(Path base)
Path relativeTo(string base)

Return this path as relative to base

remove
void remove()

Remove file or directory referenced by this path. This operation is recursive, so if path references to a direcotry, then directory itself and all content inside referenced dir will be removed

rename
void rename(Path to)
void rename(string to)

Rename current path.

toAbsolute
Path toAbsolute()

Convert path to absolute path.

toString
string toString()

Return path as string

walk
auto walk(SpanMode mode, bool followSymlink)

Iterate over all files and directories inside path;

writeFile
void writeFile(void[] buffer)

Write data to file as is

Meta