Ejemplo n.º 1
0
/*
==============
Sys_ErrorDialog

Display an error message
==============
*/
void Sys_ErrorDialog( const char *error )
{
	if( Sys_Dialog( DT_YES_NO, va( "%s. Copy console log to clipboard?", error ),
			"Error" ) == DR_YES )
	{
		HGLOBAL memoryHandle;
		char *clipMemory;

		memoryHandle = GlobalAlloc( GMEM_MOVEABLE|GMEM_DDESHARE, CON_LogSize( ) + 1 );
		clipMemory = (char *)GlobalLock( memoryHandle );

		if( clipMemory )
		{
			char *p = clipMemory;
			char buffer[ 1024 ];
			unsigned int size;

			while( ( size = CON_LogRead( buffer, sizeof( buffer ) ) ) > 0 )
			{
				Com_Memcpy( p, buffer, size );
				p += size;
			}

			*p = '\0';

			if( OpenClipboard( NULL ) && EmptyClipboard( ) )
				SetClipboardData( CF_TEXT, memoryHandle );

			GlobalUnlock( clipMemory );
			CloseClipboard( );
		}
	}
}
Ejemplo n.º 2
0
/*
==============
Sys_ErrorDialog

Display an error message
==============
*/
void Sys_ErrorDialog( const char *error )
{
	char buffer[ 1024 ];
	unsigned int size;
	fileHandle_t f;
	const char *fileName = "crashlog.txt";

	// Shut down now so that the curses console doesn't clear the screen when it's really shut down
	CON_Shutdown( );

	Sys_Print( va( "%s\n", error ) );

	// Write console log to file and to stderr
	f = FS_SV_FOpenFileWrite( fileName );
	if( !f )
	{
		Com_Printf( "ERROR: couldn't open %s\n", fileName );
		return;
	}

	while( ( size = CON_LogRead( buffer, sizeof( buffer ) ) ) > 0 )
	{
		FS_Write( buffer, size, f );
		fputs( buffer, stderr );
	}

	FS_FCloseFile( f );
}
Ejemplo n.º 3
0
/**
 * @brief Displays an error message and writes the error into crashlog.txt
 * @param[in] error Error String
 */
void Sys_ErrorDialog(const char *error)
{
	char         buffer[1024];
	unsigned int size;
	int          f         = -1;
	const char   *homepath = Cvar_VariableString("fs_homepath");
	const char   *gamedir  = Cvar_VariableString("fs_gamedir");
	const char   *fileName = "crashlog.txt";
	char         *dirpath  = FS_BuildOSPath(homepath, gamedir, "");
	char         *ospath   = FS_BuildOSPath(homepath, gamedir, fileName);

	Sys_Print(va("%s\n", error));

#ifndef DEDICATED
	// We may have grabbed input devices. Need to release.
	if (SDL_WasInit(SDL_INIT_VIDEO))
	{
		SDL_WM_GrabInput(SDL_GRAB_OFF);
	}

	Sys_Dialog(DT_ERROR, va("%s\nSee \"%s\" for details.\n", error, ospath), "Error");
#endif

	// Make sure the write path for the crashlog exists...
	// check homepath
	if (!Sys_Mkdir(homepath))
	{
		Com_Printf("ERROR: couldn't create path '%s' to write file '%s'.\n", homepath, ospath);
		return;
	}
	// check gamedir (inside homepath)
	if (!Sys_Mkdir(dirpath))
	{
		Com_Printf("ERROR: couldn't create path '%s' to write file '%s'.\n", dirpath, 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;
	}

	// 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;
		}
	}

	close(f);
}
Ejemplo n.º 4
0
/*
==============
Sys_ErrorDialog

Display an error message
==============
*/
void Sys_ErrorDialog(const char *error)
{
#if 1
	CON_SetVisibility(1);

	if(Sys_Dialog(DT_YES_NO, va("%s. Copy console log to clipboard?", error), "Error") == DR_YES)
	{
		HGLOBAL         memoryHandle;
		char           *clipMemory;

		memoryHandle = GlobalAlloc(GMEM_MOVEABLE | GMEM_DDESHARE, CON_LogSize() + 1);
		clipMemory = (char *)GlobalLock(memoryHandle);

		if(clipMemory)
		{
			char           *p = clipMemory;
			char            buffer[1024];
			unsigned int    size;

			while((size = CON_LogRead(buffer, sizeof(buffer))) > 0)
			{
				Com_Memcpy(p, buffer, size);
				p += size;
			}

			*p = '\0';

			if(OpenClipboard(NULL) && EmptyClipboard())
				SetClipboardData(CF_TEXT, memoryHandle);

			GlobalUnlock(clipMemory);
			CloseClipboard();
		}
	}
#else
	// for use with con_win32old.c
	MSG             msg;

	CON_SetVisibility(1);
	CON_SetErrorText(error);

	// wait for the user to quit
	while(1)
	{
		if(!GetMessage(&msg, NULL, 0, 0))
			break;
		TranslateMessage(&msg);
		DispatchMessage(&msg);
	}
#endif
}
Ejemplo n.º 5
0
/**
 * @brief Display an error message
 * @param[in] error Error String
 */
void Sys_ErrorDialog(const char *error)
{
	char         buffer[1024];
	unsigned int size;
	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));

#ifndef DEDICATED
	Sys_Dialog(DT_ERROR, va("%s\nSee \"%s\" for details.\n", error, ospath), "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;
	}

	// 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;
		}
	}

	close(f);
}
Ejemplo n.º 6
0
/*
==============
Sys_ErrorDialog

Display an error message
==============
*/
void Sys_ErrorDialog( const char *error )
{
	char         buffer[ 1024 ];
	unsigned int size;
	int          f;
	const char   *fileName = "crashlog.txt";
	std::string ospath = FS::Path::Build(FS::GetHomePath(), fileName);

	Sys_Print( va( "%s\n", error ) );

#ifdef BUILD_CLIENT
	// We may have grabbed input devices. Need to release.
	if ( SDL_WasInit( SDL_INIT_VIDEO ) )
	{
		SDL_SetWindowGrab( (SDL_Window*) IN_GetWindow(), SDL_FALSE );
	}

	Sys_Dialog( DT_ERROR, va( "%s. See \"%s\" for details.", error, ospath.c_str() ), "Error" );
#endif

	// 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.c_str(), O_CREAT | O_TRUNC | O_WRONLY, 0640 );

	if ( f == -1 )
	{
		Com_Printf( "ERROR: couldn't open %s\n", fileName );
		return;
	}

	// 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;
		}
	}

	close( f );
}
Ejemplo n.º 7
0
Archivo: sys.c Proyecto: icanhas/yantar
/*
 * syserrorfDialog
 *
 * Display an error message
 */
void
syserrorfDialog(const char *error)
{
	char	buffer[ 1024 ];
	unsigned int size;
	int	f = -1;
	const char *homepath = cvargetstr("fs_homepath");
	const char *gamedir = cvargetstr("fs_game");
	const char *fileName = "crashlog.txt";
	char *ospath = fsbuildospath(homepath, gamedir, fileName);

	sysprint(va("%s\n", error));
	
	if(!com_dedicated->integer)
		sysmkdialog(DT_ERROR, va("%s. See \"%s\" for details.", error,
		   ospath), "Error");

	/* Make sure the write path for the crashlog exists */
	if(fscreatepath(ospath)){
		comprintf("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 fsopenw()...use the Unix system APIs instead. */
	f = open(ospath, O_CREAT | O_TRUNC | O_WRONLY, 0640);
	if(f == -1){
		comprintf("ERROR: couldn't open %s\n", fileName);
		return;
	}

	/* 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){
			comprintf("ERROR: couldn't fully write to %s\n",
				fileName);
			break;
		}

	close(f);
}
Ejemplo n.º 8
0
/*
==============
Sys_ErrorDialog

Display an error message
==============
*/
void Sys_ErrorDialog( const char *error )
{
	char buffer[ 1024 ];
	unsigned int size;
	fileHandle_t f;
	const char *fileName = "crashlog.txt";

	Sys_Print( va( "%s\n", error ) );

	// Write console log to file
	f = FS_FOpenFileWrite( fileName );
	if( !f )
	{
		Com_Printf( "ERROR: couldn't open %s\n", fileName );
		return;
	}

	while( ( size = CON_LogRead( buffer, sizeof( buffer ) ) ) > 0 )
		FS_Write( buffer, size, f );

	FS_FCloseFile( f );
}