Menu

- Learn
- Documentation
  - Language Reference
  - Library Reference
  - Command-line Reference
  - Feature Overview
  - Articles
- Packages
- Community
  - Blog
  - Orgs using D
  - Twitter
  - Forums
  - IRC
  - Wiki
  - GitHub
  - Issues
  - Get involved
  - Foundation
  - Donate
- Resources
  - Books
  - Tutorials
  - Tools
  - Editors
  - IDEs
  - 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.

# ddmd.root.filename

Compiler implementation of the D programming language

http: //dlang.org

Authors:
Walter Bright, http://www.digitalmars.com
License:
Boost License 1.0

Source: root/filename.d

struct `FileName`;
  Encapsulate path and file names.
  static pure nothrow bool `absolute`(const(char)* `name`);
    Determine if path is `absolute`.
    Parameters:

    const(char)* `name` | path

    Returns:
    `true` if `absolute` path `name`.
  static pure nothrow const(char)* `ext`(const(char)* `str`);
    Determine file name extension as slice of input.
    Parameters:

    const(char)* `str` | file 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`);
    Return file name without extension.
    Parameters:

    const(char)* `str` | file name

    Returns:
    mem.xmalloc'd filename with extension removed.
  static pure nothrow const(char)* `name`(const(char)* `str`);
    Return filename `name` excluding path (read-only).
  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)* `defaultExt`(const(char)* `name`, const(char)* `ext`);
    Free returned value with FileName::free()
  static nothrow const(char)* `forceExt`(const(char)* `name`, const(char)* `ext`);
    Free returned value with FileName::free()
  const pure nothrow bool `equalsExt`(const(char)* `ext`);
    Return !=0 if extensions match.
  static nothrow const(char)* `searchPath`(Strings* `path`, const(char)* `name`, bool `cwd`);
    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+sources

    Returns:
    NULL file not found !=NULL mem.xmalloc'd file `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

Copyright © 1999-2017 by the D Language Foundation | Page generated by Ddoc on Fri Sep 1 12:52:29 2017