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.utils
Compiler implementation of the
D programming language.
Utility functions for DMD.
This modules defines some utility functions for DMD.
Authors:
License:
Source utils.d
Documentation https://dlang.org/phobos/dmd_utils.html
- const(char)*
toWinPath(const(char)*src); - Normalize path by turning forward slashes into backslashesParameters:
const(char)* srcSource path, using unix-style ('/') path separators Returns:A newly-allocated string with '/' turned into backslashes - FileBuffer
readFile(Locloc, const(char)*filename); - Reads a file, terminate the program on errorParameters:
Loc locThe line number information from where the call originates const(char)* filenamePath to file - void
writeFile(Locloc, const(char)[]filename, const void[]data); - Writes a file, terminate the program on errorParameters:
Loc locThe line number information from where the call originates const(char)[] filenamePath to file void[] dataFull content of the file to be written - void
ensurePathToNameExists(Locloc, const(char)[]name); - Ensure the root path (the path minus the name) of the provided path exists, and terminate the process if it doesn't.Parameters:
Loc locThe line number information from where the call originates const(char)[] namea path to check (the name is stripped) - void
escapePath(OutBuffer*buf, const(char)*fname); - Takes a path, and escapes '(', ')' and backslashesParameters:
OutBuffer* bufBuffer to write the escaped path to const(char)* fnamePath to escape - pure nothrow @nogc inout(char)[]
toDString(inout(char)*s); - Slices a \0-terminated C-string, excluding the terminator
- static bool
iequals(const(char)[]s1, const(char)[]s2); - Compare two slices for equality, in a case-insensitive wayComparison is based on char and does not do decoding. As a result, it's only really accurate for plain ASCII strings.Parameters:
const(char)[] s1string to compare const(char)[] s2string to compare Returns:true ifs1==s2regardless of case - nothrow auto
toCStringThen(alias dg)(const(char)[]src); - Copy the content of
srcinto a C-string ('\0' terminated) then call dgThe intent of this function is to provide an allocation-less way to call a C function using a D slice. The function internally allocates a buffer if needed, but frees it on exit.Note The argument to dg is scope. To keep the data around after dg exits, one has to copy it.
Parameters:const(char)[] srcSlice to use to call the C function dg Delegate to call afterwards Returns:The return value of T
Copyright © 1999-2019 by the D Language Foundation | Page generated by
Ddoc on Sun Sep 1 19:49:48 2019