mirror of
https://github.com/UberGames/ioef.git
synced 2024-12-18 00:21:40 +00:00
* Append LCC directory to the PATH variable on all platforms
This commit is contained in:
parent
151c9461c5
commit
707ee2fdbb
1 changed files with 39 additions and 24 deletions
|
@ -71,33 +71,48 @@ 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 */
|
||||||
|
|
||||||
|
/*
|
||||||
|
===============
|
||||||
|
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 <tim@ngus.net> 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 main(int argc, char *argv[]) {
|
||||||
int i, j, nf;
|
int i, j, nf;
|
||||||
|
|
||||||
#ifdef _WIN32
|
AddLCCDirToPath( argv[ 0 ] );
|
||||||
// Tim Angus <tim@ngus.net> 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, '\\' );
|
|
||||||
|
|
||||||
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];
|
progname = argv[0];
|
||||||
ac = argc + 50;
|
ac = argc + 50;
|
||||||
|
|
Loading…
Reference in a new issue