www.digitalmars.com Home | Search | D | Comments
Last update Sun Jan 22 17:22:26 2006
D
Language
Phobos
Comparisons


object

std
 std.base64
 std.boxer
 std.compiler
 std.conv
 std.cover
 std.ctype
 std.date
 std.demangle
 std.file
 std.format
 std.gc
 std.intrinsic
 std.math
 std.md5
 std.mmfile
 std.openrj
 std.outbuffer
 std.path
 std.process
 std.random
 std.recls
 std.regexp
 std.socket
 std.socketstream
 std.stdint
 std.stdio
 std.cstream
 std.stream
 std.string
 std.system
 std.thread
 std.uri
 std.utf
 std.zip
 std.zlib
 std.windows.charset

std.windows

std.linux

std.c
 std.c.stdio

std.c.windows

std.c.linux

std.path

const char[1] sep;
String used to separate directory names in a path.

const char[1] altsep;
Alternate version of sep[], used in Windows.

const char[1] pathsep;
Path separator string.

const char[2] linesep;
String used to separate lines.

const char[1] curdir;
String representing the current directory.

const char[2] pardir;
String representing the parent directory.

char[] getExt(char[] fullname);
Get extension. For example, "d:\path\foo.bat" returns "bat".

char[] getName(char[] fullname);
Get name without extension. For example, "d:\path\foo.bat" returns "d:\path\foo".

char[] getBaseName(char[] fullname);
Get base name. For example, "d:\path\foo.bat" returns "foo.bat".

char[] getDirName(char[] fullname);
Get directory name. For example, "d:\path\foo.bat" returns "d:\path".

char[] getDrive(char[] fullname);
Get drive. For example, "d:\path\foo.bat" returns "d:".

char[] defaultExt(char[] filename, char[] ext);
If filename doesn't already have an extension, append the extension ext and return the result.

char[] addExt(char[] filename, char[] ext);
Strip any existing extension off of filename and add the new extension ext. Return the result.

int isabs(char[] path);
Return !=0 if path is absolute (i.e. it starts from the root directory).

char[] join(char[] p1, char[] p2);
Join two path components p1 and p2 and return the result.

int fncharmatch(dchar c1, dchar c2);
Match file name characters c1 and c2. Case sensitivity depends on the operating system.

int fnmatch(char[] filename, char[] pattern);
Match filename with pattern, using the following wildcards:

* match 0 or more characters
? match any character
[chars] match any character that appears between the []
[!chars] match any character that does not appear between the [! ]


Matching is case sensitive on a file system that is case sensitive.

Returns:
!=0 for match

char[] expandTilde(char[] inputPath);
Performs tilde expansion in paths.

There are two ways of using tilde expansion in a path. One involves using the tilde alone or followed by a path separator. In this case, the tilde will be expanded with the value of the environment variable HOME. The second way is putting a username after the tilde (i.e. ~john/Mail). Here, the username will be searched for in the user database (i.e. /etc/passwd on Unix systems) and will expand to whatever path is stored there. The username is considered the string after the tilde ending at the first instance of a path separator.

Note that using the ~user syntax may give different values from just ~ if the environment variable doesn't match the value stored in the user database.

When the environment variable version is used, the path won't be modified if the environment variable doesn't exist. When the database version is used, the path won't be modified if the user doesn't exist in the database or there is not enough memory to perform the query.

Returns:
inputPath with the tilde expanded, or just inputPath if it could not be expanded. For Windows, expandTilde() merely returns its argument inputPath.

Throws:
std.OutOfMemory

Examples:
 import std.path;

 void process_file(char[] filename)
 {
     char[] path = expandTilde(filename);
     ...
 }
 import std.path;

 const char[] RESOURCE_DIR_TEMPLATE = "~/.applicationrc";
 char[] RESOURCE_DIR;    // This gets expanded in main().

 int main(char[][] args)
 {
     RESOURCE_DIR = expandTilde(RESOURCE_DIR_TEMPLATE);
     ...
 }


Version:
Available since v0.143.

Authors:
Grzegorz Adam Hankiewicz, Thomas Kuehne.