diff options
Diffstat (limited to 'src/sys')
-rw-r--r-- | src/sys/con_tty.c | 6 | ||||
-rw-r--r-- | src/sys/sys_unix.c | 40 | ||||
-rw-r--r-- | src/sys/sys_win32.c | 31 |
3 files changed, 50 insertions, 27 deletions
diff --git a/src/sys/con_tty.c b/src/sys/con_tty.c index a66a3faf..b0990032 100644 --- a/src/sys/con_tty.c +++ b/src/sys/con_tty.c @@ -327,7 +327,7 @@ CON_Input char *CON_Input( void ) { // we use this when sending back commands - static char text[256]; + static char text[MAX_EDIT_LINE]; int avail; char key; field_t *history; @@ -358,7 +358,7 @@ char *CON_Input( void ) { // push it in history Hist_Add(&TTY_con); - strcpy(text, TTY_con.buffer); + Q_strncpyz(text, TTY_con.buffer, sizeof(text)); Field_Clear(&TTY_con); key = '\n'; size = write(1, &key, 1); @@ -420,6 +420,8 @@ char *CON_Input( void ) CON_FlushIn(); return NULL; } + if (TTY_con.cursor >= sizeof(text) - 1) + return NULL; // push regular character TTY_con.buffer[TTY_con.cursor] = key; TTY_con.cursor++; diff --git a/src/sys/sys_unix.c b/src/sys/sys_unix.c index 3360469d..60623a27 100644 --- a/src/sys/sys_unix.c +++ b/src/sys/sys_unix.c @@ -55,22 +55,11 @@ char *Sys_DefaultHomePath(void) { Q_strncpyz( homePath, p, sizeof( homePath ) ); #ifdef MACOS_X - Q_strcat( homePath, sizeof( homePath ), "/Library" ); - mkdir( homePath, 0750 ); - Q_strcat( homePath, sizeof( homePath ), "/Application Support" ); - mkdir( homePath, 0750 ); - Q_strcat( homePath, sizeof( homePath ), "/Tremulous" ); + Q_strcat( homePath, sizeof( homePath ), + "/Library/Application Support/Tremulous" ); #else Q_strcat( homePath, sizeof( homePath ), "/.tremulous" ); #endif - if( mkdir( homePath, 0750 ) ) - { - if( errno != EEXIST ) - { - Sys_Error( "Unable to create directory \"%s\", error is %s(%d)\n", - homePath, strerror( errno ), errno ); - } - } } } @@ -222,9 +211,14 @@ const char *Sys_Dirname( char *path ) Sys_Mkdir ================== */ -void Sys_Mkdir( const char *path ) +qboolean Sys_Mkdir( const char *path ) { - mkdir( path, 0777 ); + int result = mkdir( path, 0750 ); + + if( result != 0 ) + return errno == EEXIST; + + return qtrue; } /* @@ -583,3 +577,19 @@ void Sys_PlatformInit( void ) signal( SIGIOT, Sys_SigHandler ); signal( SIGBUS, Sys_SigHandler ); } + +/* +============== +Sys_SetEnv + +set/unset environment variables (empty value removes it) +============== +*/ + +void Sys_SetEnv(const char *name, const char *value) +{ + if(value && *value) + setenv(name, value, 1); + else + unsetenv(name); +} diff --git a/src/sys/sys_win32.c b/src/sys/sys_win32.c index 18efe406..e5b0cb00 100644 --- a/src/sys/sys_win32.c +++ b/src/sys/sys_win32.c @@ -77,14 +77,6 @@ char *Sys_DefaultHomePath( void ) Q_strncpyz( homePath, szPath, sizeof( homePath ) ); Q_strcat( homePath, sizeof( homePath ), "\\Tremulous" ); FreeLibrary(shfolder); - if( !CreateDirectory( homePath, NULL ) ) - { - if( GetLastError() != ERROR_ALREADY_EXISTS ) - { - Com_Printf("Unable to create directory \"%s\"\n", homePath ); - return NULL; - } - } } return homePath; @@ -279,9 +271,15 @@ const char *Sys_Dirname( char *path ) Sys_Mkdir ============== */ -void Sys_Mkdir( const char *path ) +qboolean Sys_Mkdir( const char *path ) { - _mkdir (path); + if( !CreateDirectory( path, NULL ) ) + { + if( GetLastError( ) != ERROR_ALREADY_EXISTS ) + return qfalse; + } + + return qtrue; } /* @@ -652,3 +650,16 @@ void Sys_PlatformInit( void ) SDL_VIDEODRIVER_externallySet = qfalse; #endif } + +/* +============== +Sys_SetEnv + +set/unset environment variables (empty value removes it) +============== +*/ + +void Sys_SetEnv(const char *name, const char *value) +{ + _putenv(va("%s=%s", name, value)); +} |