char* savestring(const char* text);Create a copy of the
newand return a pointer to it. It is the caller's responsibility to assure that the string is eventually deleted by using the
delete operator. The argument
textmust not be a null pointer.
const char* hashstring(const char* text);Enters a copy of
textinto a hash table and return a pointer to the entry. If two strings compare equal when passed to
strcmp,then if both are passed to
hashstring,the return values will be the same pointer.
const char* expandPathName(const char* fileName);Expand a path name that may begin with an environment variable or a user's home directory. If the string does not begin with a ~ or
$character, the string itself is returned. A leading "
~/" is replaced by the user's home directory; a leading "~
user" is replaced by the home directory for
user,unless there is no such user, in which case the original string is returned. Finally, a leading "
$env" is replaced by the value of the environment variable
env;if there is no such environment variable, the original string is returned. Note that references to environment variables other than at the beginning are
notsubstituted. If any substitutions are made, the return value is actually a pointer into a static buffer. This means that a second call to this function may write on top of a value returned by a previous call.
const char* pathSearch(const char* file, const char* path=0);For this function,
pathis a series of Unix-style directory names, separated by colons. If no second argument is supplied or if the value is null, the value of the PATH environment variable is used instead. For each of the colon-separated directory strings, the function checks to see whether the file exists in the named directory. If it finds a match, it returns a pointer to an internal buffer containing the full path of the match. If it does not find a match, it returns a null pointer.
int progNotFound(const char* program,const char* extra=0);This function searches for
programin the user's PATH using the
pathSearchfunction. If a match is found, the function returns false (0). Otherwise it returns true (1) and also generates an error message with the
Error::abortRunfunction. If the
extraargument is given, it forms the second line of the error message.