FileName

Encapsulate path and file names.

struct FileName {}

Constructors

this
this(const(char)[] str)

Members

Functions

equalsExt
bool equalsExt(const(char)* ext)

Return !=0 if extensions match.

Static functions

absolute
bool absolute(const(char)[] name)

Determine if path is absolute.

addExt
char[] addExt(const(char)[] name, const(char)[] ext)

Add the extension ext to name, regardless of the content of name

canonicalName
const(char)* canonicalName(const(char)* name)
const(char)[] canonicalName(const(char)[] name)

Return canonical version of name in a malloc'd buffer. This code is high risk.

combine
const(char)* combine(const(char)* path, const(char)* name)
const(char)[] combine(const(char)[] path, const(char)[] name)

Combine a path and a file name

defaultExt
const(char)* defaultExt(const(char)* name, const(char)* ext)
const(char)[] defaultExt(const(char)[] name, const(char)[] ext)

Free returned value with FileName::free()

ensurePathExists
bool ensurePathExists(const(char)[] path)
bool ensurePathExists(const(char)* path)

Ensure that the provided path exists

equals
bool equals(const(char)* name1, const(char)* name2)
bool equals(const(char)[] name1, const(char)[] name2)

Compare two name according to the platform's rules (case sensitive or not)

equalsExt
bool equalsExt(const(char)* name, const(char)* ext)
bool equalsExt(const(char)[] name, const(char)[] ext)
exists
int exists(const(char)* name)
int exists(const(char)[] name)

Check if the file the path points to exists

ext
const(char)[] ext(const(char)[] str)

Determine file name extension as slice of input.

forceExt
const(char)* forceExt(const(char)* name, const(char)* ext)
const(char)[] forceExt(const(char)[] name, const(char)[] ext)

Free returned value with FileName::free()

free
void free(const(char)* str)

Free memory allocated by FileName routines

name
const(char)* name(const(char)* str)
const(char)[] name(const(char)[] str)

Return filename name excluding path (read-only).

path
const(char)* path(const(char)* str)
const(char)[] path(const(char)[] str)

Return path portion of str. returned string is newly allocated Path does not include trailing path separator.

removeExt
const(char)* removeExt(const(char)* str)
const(char)[] removeExt(const(char)[] str)

Return file name without extension.

replaceName
const(char)[] replaceName(const(char)[] path, const(char)[] name)

Replace filename portion of path.

safeSearchPath
const(char)* safeSearchPath(Strings* path, const(char)* name)

Search Path for file in a safe manner.

searchPath
const(char)* searchPath(Strings* path, const(char)* name, bool cwd)

Search paths for file.

splitPath
void splitPath(int delegate(const(char)*) nothrow sink, const(char)* path)

Split path (such as that returned by getenv("PATH")) into pieces, each piece is mem.xmalloc'd Handle double quotes and ~. Pass the pieces to sink()

toAbsolute
const(char)* toAbsolute(const(char)* name, const(char)* base = null)

Return the given name as an absolute path

Meta