Report a bug
If you spot a problem with this page, click here to create a Bugzilla issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page.
Requires a signed-in GitHub account. This works well for small changes.
If you'd like to make larger changes you may want to consider using
a local clone.
dmd.root.filename
Compiler implementation of the D programming language
http://dlang.org
Authors:
Walter Bright, http://www.digitalmars.com
License:
Source root/filename.d
Documentation https://dlang.org/phobos/dmd_root_filename.html
- struct
FileName; - Encapsulate path and file names.
- nothrow this(const(char)[]
str); - static pure nothrow bool
equals(const(char)*name1, const(char)*name2);
static pure nothrow boolequals(const(char)[]name1, const(char)[]name2); - Compare two name according to the platform's rules (case sensitive or not)
- static pure nothrow bool
absolute(const(char)*name);
static pure nothrow boolabsolute(const(char)[]name); - Determine if path is absolute.Parameters:
const(char)* namepath Returns:true if absolute path name. - static nothrow const(char)*
toAbsolute(const(char)*name, const(char)*base= null); - Return the given name as an absolute pathParameters:
const(char)* namepath const(char)* basethe absolute base to prefix name with if it is relative Returns:name as an absolute path relative to base - static pure nothrow const(char)*
ext(const(char)*str);
static pure nothrow @nogc @safe const(char)[]ext(const(char)[]str); - Determine file name extension as slice of input.Parameters:
const(char)* strfile name Returns:filename extension (read-only). Points past '.' of extension. If there isn't one, return null. - static nothrow const(char)*
removeExt(const(char)*str);
static nothrow const(char)[]removeExt(const(char)[]str); - Return file name without extension.
TODO Once slice are used everywhere and \0 is not assumed, this can be turned into a simple slicing.
Parameters:const(char)* strfile name Returns:mem.xmalloc'd filename with extension removed. - static pure nothrow const(char)*
name(const(char)*str);
static pure nothrow const(char)[]name(const(char)[]str); - Return filename name excluding path (read-only).
- static nothrow const(char)*
path(const(char)*str);
static nothrow const(char)[]path(const(char)[]str); - Return path portion of str. Path will does not include trailing path separator.
- static nothrow const(char)[]
replaceName(const(char)[]path, const(char)[]name); - Replace filename portion of path.
- static nothrow const(char)*
combine(const(char)*path, const(char)*name);
static nothrow const(char)[]combine(const(char)[]path, const(char)[]name); - Combine a
pathand a filenameParameters:const(char)* pathPath to append to const(char)* nameName to append to path Returns:The \0 terminated string which is the combination ofpathandnameand a valid path. - static nothrow char[]
addExt(const(char)[]name, const(char)[]ext); - Add the extension
exttoname, regardless of the content ofnameParameters:const(char)[] namePath to append the extension to const(char)[] extExtension to add (should not include '.') Returns:A newly allocated string (free with FileName.free) - static nothrow const(char)*
defaultExt(const(char)*name, const(char)*ext);
static nothrow const(char)[]defaultExt(const(char)[]name, const(char)[]ext); - Free returned value with FileName::free()
- static nothrow const(char)*
forceExt(const(char)*name, const(char)*ext);
static nothrow const(char)[]forceExt(const(char)[]name, const(char)[]ext); - Free returned value with FileName::free()
- static pure nothrow bool
equalsExt(const(char)*name, const(char)*ext);
static pure nothrow boolequalsExt(const(char)[]name, const(char)[]ext); - Returns:true if
name's extension isext - const pure nothrow bool
equalsExt(const(char)*ext); - Return !=0 if extensions match.
- static nothrow const(char)*
searchPath(Strings*path, const(char)*name, boolcwd); - Search Path for file.
Input cwd if true, search current directory before searching path
- static nothrow const(char)*
safeSearchPath(Strings*path, const(char)*name); - Search Path for file in a safe manner.Be wary of CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal') attacks. http://cwe.mitre.org/data/definitions/22.html More info: https://www.securecoding.cert.org/confluence/display/c/FIO02-C.+Canonicalize+path+names+originating+from+tainted+sourcesReturns:NULL file not found !=NULL mem.xmalloc'd file name
- static nothrow int
exists(const(char)*name);
static nothrow intexists(const(char)[]name); - Check if the file the path points to existsReturns:0 if it does not exists 1 if it exists and is not a directory 2 if it exists and is a directory
- static nothrow bool
ensurePathExists(const(char)*path); - Ensure that the provided path existsAccepts a path to either a file or a directory. In the former case, the basepath (path to the containing directory) will be checked for existence, and created if it does not exists. In the later case, the directory pointed to will be checked for existence and created if needed.Parameters:
const(char)* patha path to a file or a directory Returns:true if the directory exists or was successfully created - static nothrow const(char)*
canonicalName(const(char)*name);
static nothrow const(char)[]canonicalName(const(char)[]name); - Return canonical version of name in a malloc'd buffer. This code is high risk.
- static nothrow void
free(const(char)*str); - Free memory allocated by FileName routines
- auto
absPathThen(alias F)(const(char)[]fileName); - Takes a callable F and applies it to the result of converting
fileNameto an absolute file path (char*)Parameters:const(char)[] fileNameThe file name to be converted to an absolute path Returns:Whatever F returns.
Copyright © 1999-2018 by the D Language Foundation | Page generated by
Ddoc on Thu Nov 1 12:28:31 2018