diff options
Diffstat (limited to 'src/sys/sys_unix.c')
-rw-r--r-- | src/sys/sys_unix.c | 58 |
1 files changed, 49 insertions, 9 deletions
diff --git a/src/sys/sys_unix.c b/src/sys/sys_unix.c index b55bbe6d..3360469d 100644 --- a/src/sys/sys_unix.c +++ b/src/sys/sys_unix.c @@ -35,6 +35,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include <sys/time.h> #include <pwd.h> #include <libgen.h> +#include <fcntl.h> // Used to determine where to store user-specific files static char homePath[ MAX_OSPATH ] = { 0 }; @@ -54,11 +55,15 @@ char *Sys_DefaultHomePath(void) { Q_strncpyz( homePath, p, sizeof( homePath ) ); #ifdef MACOS_X - Q_strcat( homePath, sizeof( homePath ), "/Library/Application Support/Tremulous" ); + 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" ); #else Q_strcat( homePath, sizeof( homePath ), "/.tremulous" ); #endif - if( mkdir( homePath, 0777 ) ) + if( mkdir( homePath, 0750 ) ) { if( errno != EEXIST ) { @@ -497,23 +502,58 @@ void Sys_ErrorDialog( const char *error ) { char buffer[ 1024 ]; unsigned int size; - fileHandle_t f; + int f = -1; + const char *homepath = Cvar_VariableString( "fs_homepath" ); + const char *gamedir = Cvar_VariableString( "fs_gamedir" ); const char *fileName = "crashlog.txt"; + char *ospath = FS_BuildOSPath( homepath, gamedir, fileName ); Sys_Print( va( "%s\n", error ) ); - // Write console log to file - f = FS_FOpenFileWrite( fileName ); - if( !f ) +#if defined(MACOS_X) && !DEDICATED + /* This function has to be in a separate file, compiled as Objective-C. */ + extern void Cocoa_MsgBox( const char *text ); + if (!com_dedicated || !com_dedicated->integer) + Cocoa_MsgBox(error); +#endif + + /* make sure the write path for the crashlog exists... */ + if( FS_CreatePath( ospath ) ) { + Com_Printf( "ERROR: couldn't create path '%s' for crash log.\n", ospath ); + return; + } + + /* we might be crashing because we maxed out the Quake MAX_FILE_HANDLES, + which will come through here, so we don't want to recurse forever by + calling FS_FOpenFileWrite()...use the Unix system APIs instead. */ + f = open(ospath, O_CREAT | O_TRUNC | O_WRONLY, 0640); + if( f == -1 ) { Com_Printf( "ERROR: couldn't open %s\n", fileName ); return; } - while( ( size = CON_LogRead( buffer, sizeof( buffer ) ) ) > 0 ) - FS_Write( buffer, size, f ); + /* We're crashing, so we don't care much if write() or close() fails. */ + while( ( size = CON_LogRead( buffer, sizeof( buffer ) ) ) > 0 ) { + if (write( f, buffer, size ) != size) { + Com_Printf( "ERROR: couldn't fully write to %s\n", fileName ); + break; + } + } - FS_FCloseFile( f ); + close(f); +} + +/* +============== +Sys_GLimpSafeInit + +Unix specific "safe" GL implementation initialisation +============== +*/ +void Sys_GLimpSafeInit( void ) +{ + // NOP } /* |