mirror of
https://github.com/cc65/cc65.git
synced 2024-09-30 08:57:49 +00:00
New function AddSubSearchPathFromEnv.
git-svn-id: svn://svn.cc65.org/cc65/trunk@4208 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
parent
7adc9311be
commit
a9e46e245a
@ -6,10 +6,10 @@
|
|||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* (C) 2000-2008 Ullrich von Bassewitz */
|
/* (C) 2000-2009, Ullrich von Bassewitz */
|
||||||
/* Roemerstrasse 52 */
|
/* Roemerstrasse 52 */
|
||||||
/* D-70794 Filderstadt */
|
/* D-70794 Filderstadt */
|
||||||
/* EMail: uz@cc65.org */
|
/* EMail: uz@cc65.org */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* This software is provided 'as-is', without any expressed or implied */
|
/* This software is provided 'as-is', without any expressed or implied */
|
||||||
@ -132,7 +132,7 @@ static char* Find (const char* Path, const char* File)
|
|||||||
SB_AppendChar (&PathName, '/');
|
SB_AppendChar (&PathName, '/');
|
||||||
}
|
}
|
||||||
SB_AppendStr (&PathName, File);
|
SB_AppendStr (&PathName, File);
|
||||||
SB_Terminate (&PathName);
|
SB_Terminate (&PathName);
|
||||||
|
|
||||||
/* Check if this file exists */
|
/* Check if this file exists */
|
||||||
if (access (SB_GetBuf (&PathName), 0) == 0) {
|
if (access (SB_GetBuf (&PathName), 0) == 0) {
|
||||||
@ -173,13 +173,51 @@ void AddSearchPath (const char* NewPath, unsigned Where)
|
|||||||
|
|
||||||
|
|
||||||
void AddSearchPathFromEnv (const char* EnvVar, unsigned Where)
|
void AddSearchPathFromEnv (const char* EnvVar, unsigned Where)
|
||||||
/* Add a search from an environment variable */
|
/* Add a search path from an environment variable */
|
||||||
{
|
{
|
||||||
AddSearchPath (getenv (EnvVar), Where);
|
AddSearchPath (getenv (EnvVar), Where);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void AddSubSearchPathFromEnv (const char* EnvVar, const char* SubDir, unsigned Where)
|
||||||
|
/* Add a search path from an environment variable, adding a subdirectory to
|
||||||
|
* the environment variable value.
|
||||||
|
*/
|
||||||
|
{
|
||||||
|
StrBuf Dir = AUTO_STRBUF_INITIALIZER;
|
||||||
|
|
||||||
|
const char* EnvVal = getenv (EnvVar);
|
||||||
|
if (EnvVal == 0) {
|
||||||
|
/* Not found */
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Copy the environment variable to the buffer */
|
||||||
|
SB_CopyStr (&Dir, EnvVal);
|
||||||
|
|
||||||
|
/* Add a path separator if necessary */
|
||||||
|
if (SB_NotEmpty (&Dir)) {
|
||||||
|
if (SB_LookAtLast (&Dir) != '\\' && SB_LookAtLast (&Dir) != '/') {
|
||||||
|
SB_AppendChar (&Dir, '/');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Add the subdirectory */
|
||||||
|
SB_AppendStr (&Dir, SubDir);
|
||||||
|
|
||||||
|
/* Terminate the string */
|
||||||
|
SB_Terminate (&Dir);
|
||||||
|
|
||||||
|
/* Add the search path */
|
||||||
|
AddSearchPath (SB_GetConstBuf (&Dir), Where);
|
||||||
|
|
||||||
|
/* Free the temp buffer */
|
||||||
|
SB_Done (&Dir);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void ForgetAllSearchPaths (unsigned Where)
|
void ForgetAllSearchPaths (unsigned Where)
|
||||||
/* Forget all search paths in the given lists. */
|
/* Forget all search paths in the given lists. */
|
||||||
{
|
{
|
||||||
|
@ -6,10 +6,10 @@
|
|||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* (C) 2000-2003 Ullrich von Bassewitz */
|
/* (C) 2000-2009, Ullrich von Bassewitz */
|
||||||
/* Römerstrasse 52 */
|
/* Roemerstrasse 52 */
|
||||||
/* D-70794 Filderstadt */
|
/* D-70794 Filderstadt */
|
||||||
/* EMail: uz@cc65.org */
|
/* EMail: uz@cc65.org */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* This software is provided 'as-is', without any expressed or implied */
|
/* This software is provided 'as-is', without any expressed or implied */
|
||||||
@ -67,7 +67,12 @@ void AddSearchPath (const char* NewPath, unsigned Where);
|
|||||||
/* Add a new search path to the existing one */
|
/* Add a new search path to the existing one */
|
||||||
|
|
||||||
void AddSearchPathFromEnv (const char* EnvVar, unsigned Where);
|
void AddSearchPathFromEnv (const char* EnvVar, unsigned Where);
|
||||||
/* Add a search from an environment variable */
|
/* Add a search path from an environment variable */
|
||||||
|
|
||||||
|
void AddSubSearchPathFromEnv (const char* EnvVar, const char* SubDir, unsigned Where);
|
||||||
|
/* Add a search path from an environment variable, adding a subdirectory to
|
||||||
|
* the environment variable value.
|
||||||
|
*/
|
||||||
|
|
||||||
void ForgetAllSearchPaths (unsigned Where);
|
void ForgetAllSearchPaths (unsigned Where);
|
||||||
/* Forget all search paths in the given lists. */
|
/* Forget all search paths in the given lists. */
|
||||||
|
Loading…
Reference in New Issue
Block a user