From 079f24d46b34fbe15812e51fb09d185c379f0c56 Mon Sep 17 00:00:00 2001 From: tma Date: Wed, 5 Oct 2005 21:46:03 +0000 Subject: * Append LCC directory to the PATH variable on all platforms git-svn-id: svn://svn.icculus.org/quake3/trunk@144 edf5b092-35ff-0310-97b2-ce42778d08ea --- code/tools/lcc/etc/lcc.c | 63 ++++++++++++++++++++++++++++++------------------ 1 file changed, 39 insertions(+), 24 deletions(-) (limited to 'code/tools') diff --git a/code/tools/lcc/etc/lcc.c b/code/tools/lcc/etc/lcc.c index 4a6d0f6..01257fe 100644 --- a/code/tools/lcc/etc/lcc.c +++ b/code/tools/lcc/etc/lcc.c @@ -71,34 +71,49 @@ char *tempdir = TEMPDIR; /* directory for temporary files */ static char *progname; static List lccinputs; /* list of input directories */ +/* +=============== +AddLCCDirToPath + +Append the base path of this file to the PATH so that q3lcc can find q3cpp and +q3rcc in its own directory. There are probably (much) cleaner ways of doing +this. +Tim Angus 05/09/05 +=============== +*/ +void AddLCCDirToPath( const char *lccBinary ) +{ + char basepath[ 1024 ]; + char path[ 4096 ]; + char *p; + + strncpy( basepath, lccBinary, 1024 ); + p = strrchr( basepath, '/' ); + if( !p ) + p = strrchr( basepath, '\\' ); + + if( p ) + { + *p = '\0'; + strncpy( path, "PATH=", 4096 ); + strncat( path, getenv( "PATH" ), 4096 ); +#ifdef _WIN32 + strncat( path, ";", 4096 ); + strncat( path, basepath, 4096 ); + _putenv( path ); +#else + strncat( path, ":", 4096 ); + strncat( path, basepath, 4096 ); + putenv( path ); +#endif + } +} + int main(int argc, char *argv[]) { int i, j, nf; - -#ifdef _WIN32 - // Tim Angus 05/09/05 - // Append the base path of this file to the PATH - // There are probably (much) cleaner ways of doing this, but - // IANAWD (Windows Developer) - { - char basepath[ 1024 ]; - char path[ 4096 ]; - char *p; - strncpy( basepath, argv[ 0 ], 1024 ); - p = strrchr( basepath, '\\' ); + AddLCCDirToPath( argv[ 0 ] ); - if( p ) - { - *p = '\0'; - strncpy( path, "PATH=", 4096 ); - strncat( path, getenv( "PATH" ), 4096 ); - strncat( path, ";", 4096 ); - strncat( path, basepath, 4096 ); - _putenv( path ); - } - } -#endif - progname = argv[0]; ac = argc + 50; av = alloc(ac*sizeof(char *)); -- cgit v1.2.3