Movatterモバイル変換


[0]ホーム

URL:


D Logo
Menu
Search

Library Reference

version 2.112.0

overview

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 usinga local clone.

dmd.root.filename

Encapsulate path and file names.
Authors:
Walter Bright,https://www.digitalmars.com
License:
Boost License 1.0

Sourceroot/filename.d

Documentationhttps://dlang.org/phobos/dmd_root_filename.html

Coveragehttps://codecov.io/gh/dlang/dmd/src/master/compiler/src/dmd/root/filename.d

structFileName;
Encapsulate path and file names.
pure nothrow this(const char[]str);
static pure nothrow FileNamecreate(const(char)*name);
static pure nothrow @nogc boolequals(const(char)*name1, const(char)*name2);

static pure nothrow @nogc boolequals(const char[]name1, const char[]name2);
Compare two name according to the platform's rules (case sensitive or not)
static pure nothrow @nogc boolabsolute(const(char)*name);

static pure nothrow @nogc @safe 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 path
Parameters:
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 @nogc 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.

TODOOnce 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 nothrow @safe const(char)[]sansExt(const char[]filename);
Slice of file name without extension.
Parameters:
char[]filenamefile name
Returns:
the slice
static pure nothrow @nogc const(char)*name(const(char)*str);

static pure nothrow @nogc @safe 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. returned string is newly allocated Path 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 apath and a filename
Parameters:
const(char)*pathPath to append to
const(char)*nameName to append to path
Returns:
The\0 terminated string which is the combination ofpath andname and a valid path.
static nothrow voidappendSplitPath(const(char)*path, ref Stringsarray);
Splits a delimiter-separated path string (e.g., from an environment variable likePATH) into individual path fragments and appends them to the given array.
This is a convenience wrapper aroundsplitPath that collects all fragments into anArray!(const(char)*).
Parameters:
const(char)*pathA null-terminated string containing path fragments separated by platform-specific delimiters.
StringsarrayThe array to which each extracted fragment will be appended.
See Also:
splitPath
static nothrow voidsplitPath(scope int delegate(const(char)*) nothrowsink, const(char)*path);
Split path (such as that returned bygetenv("PATH")) into pieces, each piece is mem.xmalloc'd Handle double quotes and ~. Pass the pieces to sink()
Parameters:
int delegate(const(char)*) nothrowsinksend the path pieces here, end when sink() returns !=0
const(char)*paththe path to split up.
static pure nothrow char[]addExt(const char[]name, const char[]ext);
Add the extensionext toname, regardless of the content ofname
Parameters:
char[]namePath to append the extension to
char[]extExtension to add (should not include '.')
Returns:
A newly allocated string (free withFileName.free)
static pure nothrow const(char)*defaultExt(const(char)*name, const(char)*ext);

static pure nothrow const(char)[]defaultExt(const char[]name, const char[]ext);
Free returned value with FileName::free()
static pure nothrow const(char)*forceExt(const(char)*name, const(char)*ext);

static pure nothrow const(char)[]forceExt(const char[]name, const char[]ext);
Free returned value with FileName::free()
static pure nothrow @nogc boolequalsExt(const(char)*name, const(char)*ext);

static pure nothrow @nogc boolequalsExt(const char[]name, const char[]ext);
Returns:
true ifname's extension isext
pure nothrow @nogc boolequalsExt(const(char)*ext) const;
Return !=0 if extensions match.
static nothrow const(char)*searchPath(ref const Stringspath, const(char)*name, boolcwd);
Search paths for file.
Parameters:
Stringspatharray of path strings
const(char)*namefile to look for
boolcwdtrue means search current directory before searching path
Returns:
if found, filename combined with path, otherwise null
static pure nothrow @nogc @safe size_tfindReservedChar(const char[]name);
Determine if path contains reserved character.
Parameters:
char[]namepath
Returns:
index of the first reserved character in path if found, size_t.max otherwise
static pure nothrow @nogc @safe boolrefersToParentDir(const char[]name);
Determine if path has a reference to parent directory.
Parameters:
char[]namepath
Returns:
true if path contains '..' reference to parent directory
static nothrow intexists(const(char)*name);

static nothrow intexists(const char[]name);
Check if the file thepath points to exists
Returns:
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 boolensurePathExists(const char[]path);

static nothrow boolensurePathExists(const(char)*path);
Ensure that the provided path exists
Accepts 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:
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. This code is high risk.
static pure nothrow voidfree(const(char)*str);
Free memory allocated by FileName routines
Copyright © 1999-2026 by theD Language Foundation | Page generated byDdoc on Sat Feb 21 00:04:46 2026

[8]ページ先頭

©2009-2026 Movatter.jp