* Append LCC directory to the PATH variable on all platforms

This commit is contained in:
Tim Angus 2005-10-05 21:46:03 +00:00
parent 151c9461c5
commit 707ee2fdbb

View file

@ -71,20 +71,25 @@ char *tempdir = TEMPDIR; /* directory for temporary files */
static char *progname; static char *progname;
static List lccinputs; /* list of input directories */ static List lccinputs; /* list of input directories */
int main(int argc, char *argv[]) { /*
int i, j, nf; ===============
AddLCCDirToPath
#ifdef _WIN32 Append the base path of this file to the PATH so that q3lcc can find q3cpp and
// Tim Angus <tim@ngus.net> 05/09/05 q3rcc in its own directory. There are probably (much) cleaner ways of doing
// Append the base path of this file to the PATH this.
// There are probably (much) cleaner ways of doing this, but Tim Angus <tim@ngus.net> 05/09/05
// IANAWD (Windows Developer) ===============
*/
void AddLCCDirToPath( const char *lccBinary )
{ {
char basepath[ 1024 ]; char basepath[ 1024 ];
char path[ 4096 ]; char path[ 4096 ];
char *p; char *p;
strncpy( basepath, argv[ 0 ], 1024 ); strncpy( basepath, lccBinary, 1024 );
p = strrchr( basepath, '/' );
if( !p )
p = strrchr( basepath, '\\' ); p = strrchr( basepath, '\\' );
if( p ) if( p )
@ -92,12 +97,22 @@ int main(int argc, char *argv[]) {
*p = '\0'; *p = '\0';
strncpy( path, "PATH=", 4096 ); strncpy( path, "PATH=", 4096 );
strncat( path, getenv( "PATH" ), 4096 ); strncat( path, getenv( "PATH" ), 4096 );
#ifdef _WIN32
strncat( path, ";", 4096 ); strncat( path, ";", 4096 );
strncat( path, basepath, 4096 ); strncat( path, basepath, 4096 );
_putenv( path ); _putenv( path );
} #else
} strncat( path, ":", 4096 );
strncat( path, basepath, 4096 );
putenv( path );
#endif #endif
}
}
int main(int argc, char *argv[]) {
int i, j, nf;
AddLCCDirToPath( argv[ 0 ] );
progname = argv[0]; progname = argv[0];
ac = argc + 50; ac = argc + 50;