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.

execute
auto execute(string[] args, string[string] env, P workDir, std.process.Config config, size_t maxOutput)

Execute the file pointed by path * * Params: * args = arguments to be passed to program * env = associative array that represent environment variables * to be passed to program pointed by path * workDir = Working directory for new process. * config = Parameters for process creation. * See See std.process.Config * maxOutput = Max bytes of output to be captured * Returns: * An std.typecons.Tuple!(int, "status", string, "output").

execute
auto execute(string[] args, string[string] env, P workDir, std.process.Config config, size_t maxOutput)

Execute the file pointed by path * * Params: * args = arguments to be passed to program * env = associative array that represent environment variables * to be passed to program pointed by path * workDir = Working directory for new process. * config = Parameters for process creation. * See See std.process.Config * maxOutput = Max bytes of output to be captured * Returns: * An std.typecons.Tuple!(int, "status", string, "output").

exists
bool exists()

Check if path exists

expandTilde
Path expandTilde()

Expand tilde (~) in current path.

extension
string extension()

Returns extension for current path

getAttributes
auto getAttributes()

Get attributes of the path

getSize
ulong getSize()

Return size of file specified by path

hasAttributes
bool hasAttributes(uint attributes)

Check if file has numeric attributes. This method check if all bits specified by param 'attributes' are set.

isAbsolute
bool isAbsolute()

Check if path is absolute

isDir
bool isDir()

Determine if path is directory.

isFile
bool isFile()

Determine if path is file.

isNull
bool isNull()

Check if path is null

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.

readFileText
auto readFileText()

Read text content of the file. Technicall just a call to std.file.readText.

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.

searchFileUp
Path searchFileUp(string file_name)
Path searchFileUp(Path search_path)

Search file by name in current directory and parent directories. * Usually, this could be used to find project config, * when current directory is somewhere inside project. * * If no file with specified name found, then return null path. * * Params: * file_name = Name of file to search * Returns: * Path to searched file, if such file was found. * Otherwise return null Path.

setAttributes
void setAttributes(uint attributes)

Set attributes of the path * * Params: * attributes = value representing attributes to set on path.

symlink
void symlink(Path dest)

Create symlink for this file in dest 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

Static functions

current
Path current()

Return current path (as absolute path)

Meta