Menu

- Learn
- Documentation
  - Language Reference
  - Library Reference
  - Command-line Reference
  - Feature Overview
  - Articles
- Downloads
- Packages
- Community
  - Blog
  - Orgs using D
  - Twitter
  - Calendar
  - Forums
  - IRC
  - Community Discord
  - Wiki
  - GitHub
  - Issues
  - Get involved
  - Contributors
  - Foundation
  - Security Team
  - Donate
  - Sponsors
- Resources
  - Tour
  - Books
  - Tutorials
  - Tools
  - Editors
  - IDEs
  - run.dlang.io
  - Visual D
  - Acknowledgments
  - D Style
  - Glossary
  - Sitemap

Search
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:
Walter Bright
License:
Boost License 1.0

Source utils.d

Documentation https://dlang.org/phobos/dmd_utils.html

Coverage https://codecov.io/gh/dlang/dmd/src/master/src/dmd/utils.d

const(char)* `toWinPath`(const(char)* `src`);
  Normalize path by turning forward slashes into backslashes
  Parameters:

  const(char)* `src` | Source path, using unix-style ('/') path separators

  Returns:
  A newly-allocated string with '/' turned into backslashes
FileBuffer `readFile`(Loc `loc`, const(char)* `filename`);
  Reads a file, terminate the program on error
  Parameters:

  Loc `loc` | The line number information from where the call originates
  const(char)* `filename` | Path to file

void `writeFile`(Loc `loc`, const(char)[] `filename`, const void[] `data`);
  Writes a file, terminate the program on error
  Parameters:

  Loc `loc` | The line number information from where the call originates
  const(char)[] `filename` | Path to file
  void[] `data` | Full content of the file to be written

void `ensurePathToNameExists`(Loc `loc`, 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 `loc` | The line number information from where the call originates
  const(char)[] `name` | a path to check (the name is stripped)

void `escapePath`(OutBuffer* `buf`, const(char)* `fname`);
  Takes a path, and escapes '(', ')' and backslashes
  Parameters:

  OutBuffer* `buf` | Buffer to write the escaped path to
  const(char)* `fname` | Path to escape

Copyright © 1999-2020 by the D Language Foundation | Page generated by Ddoc on Mon Mar 9 06:17:04 2020