cnq3/code/win32/win_shared.cpp
myT 9a7ab19245 sv_restartProcess restarts the child process
uptime print child process, parent process and map uptimes
2017-10-12 03:45:24 +02:00

84 lines
2 KiB
C++

/*
===========================================================================
Copyright (C) 1999-2005 Id Software, Inc.
This file is part of Quake III Arena source code.
Quake III Arena source code is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
Quake III Arena source code is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Quake III Arena source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
#include "../qcommon/q_shared.h"
#include "../qcommon/qcommon.h"
#include "win_local.h"
int Sys_Milliseconds()
{
static int sys_timeBase = 0;
if (!sys_timeBase)
sys_timeBase = timeGetTime();
return (timeGetTime() - sys_timeBase);
}
const char* Sys_DefaultHomePath()
{
return NULL;
}
qbool Sys_HardReboot()
{
return qfalse;
}
qbool Sys_HasCNQ3Parent()
{
return qfalse;
}
int Sys_GetUptimeSeconds( qbool parent )
{
if (parent)
return -1;
FILETIME startFileTime;
FILETIME trash[3];
if (GetProcessTimes(GetCurrentProcess(), &startFileTime, &trash[0], &trash[1], &trash[2]) == 0)
return -1;
SYSTEMTIME endSystemTime;
GetSystemTime(&endSystemTime);
FILETIME endFileTime;
if (SystemTimeToFileTime(&endSystemTime, &endFileTime) == 0)
return -1;
// 1 FILETIME unit is 100-nanoseconds
ULARGE_INTEGER start, end;
start.LowPart = startFileTime.dwLowDateTime;
start.HighPart = startFileTime.dwHighDateTime;
end.LowPart = endFileTime.dwLowDateTime;
end.HighPart = endFileTime.dwHighDateTime;
const int seconds = (int)((end.QuadPart - start.QuadPart) / 1e7);
return seconds;
}