mirror of
https://git.code.sf.net/p/quake/quakeforge-old
synced 2025-03-21 08:21:27 +00:00
Moved Sys_mkdir() and Sys_DoubleTime() into common/sys_common.c
This commit is contained in:
parent
ad0b6604f6
commit
983243b577
9 changed files with 61 additions and 203 deletions
|
@ -33,6 +33,12 @@
|
|||
#ifdef HAVE_SYS_STAT_H
|
||||
# include <sys/stat.h>
|
||||
#endif
|
||||
#ifdef HAVE_SYS_TIME_H
|
||||
# include <sys/time.h>
|
||||
#endif
|
||||
#ifdef HAVE_SYS_TIMEB_H
|
||||
# include <sys/timeb.h>
|
||||
#endif
|
||||
|
||||
|
||||
int nostdout = 0;
|
||||
|
@ -68,6 +74,23 @@ void Sys_Printf (char *fmt, ...)
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
================
|
||||
Sys_mkdir
|
||||
================
|
||||
*/
|
||||
void Sys_mkdir (char *path)
|
||||
{
|
||||
#if defined(_WIN32)
|
||||
_mkdir(path);
|
||||
#elif defined(HAVE_MKDIR)
|
||||
mkdir(path, 0777);
|
||||
#else
|
||||
# warning No mkdir() - creating directories will not be possible
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
============
|
||||
Sys_FileTime
|
||||
|
@ -100,3 +123,41 @@ int Sys_FileTime (char *path)
|
|||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
================
|
||||
Sys_DoubleTime
|
||||
================
|
||||
*/
|
||||
double Sys_DoubleTime(void)
|
||||
{
|
||||
static int starttime = 0;
|
||||
long secs, usecs;
|
||||
|
||||
#if defined(HAVE_GETTIMEOFDAY)
|
||||
struct timeval tp;
|
||||
|
||||
gettimeofday(&tp, NULL);
|
||||
secs = tp.tv_sec;
|
||||
usecs = tp.tv_usec;
|
||||
#elif defined(HAVE_FTIME)
|
||||
struct timeb tstruct;
|
||||
|
||||
ftime(&tstruct);
|
||||
secs = tstruct.time;
|
||||
usecs = tstruct.millitm*1000;
|
||||
#elif defined(HAVE__FTIME)
|
||||
struct _timeb tstruct;
|
||||
|
||||
_ftime(&tstruct);
|
||||
secs = tstruct.time;
|
||||
usecs = tstruct.millitm*1000;
|
||||
#else
|
||||
# error You need to implement Sys_DoubleTime()
|
||||
#endif
|
||||
|
||||
if (!starttime) starttime = secs;
|
||||
|
||||
return (secs - starttime) + usecs/1000000.0;
|
||||
}
|
||||
|
|
|
@ -104,10 +104,6 @@ void Sys_Warn (char *warning, ...) {
|
|||
fprintf(stderr, "Warning: %s", string);
|
||||
}
|
||||
|
||||
void Sys_mkdir (char *path) {
|
||||
mkdir (path, 0777);
|
||||
}
|
||||
|
||||
int Sys_FileOpenRead (char *path, int *handle) {
|
||||
|
||||
int h;
|
||||
|
@ -190,21 +186,6 @@ void Sys_EditFile(char *filename) {
|
|||
}
|
||||
}
|
||||
|
||||
double Sys_DoubleTime (void) {
|
||||
|
||||
struct timeval tp;
|
||||
struct timezone tzp;
|
||||
static int secbase;
|
||||
|
||||
gettimeofday(&tp, &tzp);
|
||||
|
||||
if (!secbase) {
|
||||
secbase = tp.tv_sec;
|
||||
return tp.tv_usec/1000000.0;
|
||||
}
|
||||
return (tp.tv_sec - secbase) + tp.tv_usec/1000000.0;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// Sleeps for microseconds
|
||||
// =======================================================================
|
||||
|
|
|
@ -115,11 +115,6 @@ int Sys_FileWrite (int handle, void *data, int count)
|
|||
return fwrite (data, 1, count, sys_handles[handle]);
|
||||
}
|
||||
|
||||
void Sys_mkdir (char *path)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
System I/O
|
||||
*/
|
||||
|
@ -150,15 +145,6 @@ void Sys_Quit (void)
|
|||
exit (0);
|
||||
}
|
||||
|
||||
double Sys_DoubleTime (void)
|
||||
{
|
||||
static double t;
|
||||
|
||||
t += 0.1;
|
||||
|
||||
return t;
|
||||
}
|
||||
|
||||
char *Sys_ConsoleInput (void)
|
||||
{
|
||||
return NULL;
|
||||
|
|
|
@ -97,12 +97,6 @@ int filelength (FILE *f)
|
|||
#endif
|
||||
|
||||
|
||||
void Sys_mkdir (char *path)
|
||||
{
|
||||
_mkdir (path);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
===============================================================================
|
||||
|
||||
|
@ -337,30 +331,6 @@ void Sys_InitFloatTime (void)
|
|||
|
||||
#endif
|
||||
|
||||
double Sys_DoubleTime (void)
|
||||
{
|
||||
static DWORD starttime;
|
||||
static qboolean first = true;
|
||||
DWORD now;
|
||||
double t;
|
||||
|
||||
now = timeGetTime();
|
||||
|
||||
if (first) {
|
||||
first = false;
|
||||
starttime = now;
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
if (now < starttime) // wrapped?
|
||||
return (now / 1000.0) + (LONG_MAX - starttime / 1000.0);
|
||||
|
||||
if (now - starttime == 0)
|
||||
return 0.0;
|
||||
|
||||
return (now - starttime) / 1000.0;
|
||||
}
|
||||
|
||||
char *Sys_ConsoleInput (void)
|
||||
{
|
||||
static char text[256];
|
||||
|
|
|
@ -47,43 +47,6 @@ qboolean stdin_ready;
|
|||
===============================================================================
|
||||
*/
|
||||
|
||||
/*
|
||||
============
|
||||
Sys_mkdir
|
||||
|
||||
============
|
||||
*/
|
||||
void Sys_mkdir (char *path)
|
||||
{
|
||||
if (mkdir (path, 0777) != -1)
|
||||
return;
|
||||
if (errno != EEXIST)
|
||||
Sys_Error ("mkdir %s: %s",path, strerror(errno));
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
================
|
||||
Sys_DoubleTime
|
||||
================
|
||||
*/
|
||||
double Sys_DoubleTime (void)
|
||||
{
|
||||
struct timeval tp;
|
||||
struct timezone tzp;
|
||||
static int secbase;
|
||||
|
||||
gettimeofday(&tp, &tzp);
|
||||
|
||||
if (!secbase)
|
||||
{
|
||||
secbase = tp.tv_sec;
|
||||
return tp.tv_usec/1000000.0;
|
||||
}
|
||||
|
||||
return (tp.tv_sec - secbase) + tp.tv_usec/1000000.0;
|
||||
}
|
||||
|
||||
/*
|
||||
================
|
||||
Sys_Error
|
||||
|
|
|
@ -26,17 +26,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
|
||||
extern cvar_t sys_nostdout;
|
||||
|
||||
/*
|
||||
================
|
||||
Sys_mkdir
|
||||
================
|
||||
*/
|
||||
void Sys_mkdir (char *path)
|
||||
{
|
||||
_mkdir(path);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
================
|
||||
Sys_Error
|
||||
|
@ -58,27 +47,6 @@ void Sys_Error (char *error, ...)
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
================
|
||||
Sys_DoubleTime
|
||||
================
|
||||
*/
|
||||
double Sys_DoubleTime (void)
|
||||
{
|
||||
double t;
|
||||
struct _timeb tstruct;
|
||||
static int starttime;
|
||||
|
||||
_ftime( &tstruct );
|
||||
|
||||
if (!starttime)
|
||||
starttime = tstruct.time;
|
||||
t = (tstruct.time-starttime) + tstruct.millitm*0.001;
|
||||
|
||||
return t;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
================
|
||||
Sys_ConsoleInput
|
||||
|
|
|
@ -173,11 +173,6 @@ int Sys_FileWrite (int handle, void *data, int count)
|
|||
return fwrite (data, 1, count, sys_handles[handle].hFile);
|
||||
}
|
||||
|
||||
void Sys_mkdir (char *path)
|
||||
{
|
||||
mkdir( path, 0777 );
|
||||
}
|
||||
|
||||
/*
|
||||
===============================================================================
|
||||
|
||||
|
@ -225,23 +220,6 @@ void Sys_Quit (void)
|
|||
exit (0);
|
||||
}
|
||||
|
||||
double Sys_DoubleTime (void)
|
||||
{
|
||||
struct timeval tp;
|
||||
struct timezone tzp;
|
||||
static int secbase;
|
||||
|
||||
gettimeofday(&tp, &tzp);
|
||||
|
||||
if (!secbase)
|
||||
{
|
||||
secbase = tp.tv_sec;
|
||||
return tp.tv_usec/1000000.0;
|
||||
}
|
||||
|
||||
return (tp.tv_sec - secbase) + tp.tv_usec/1000000.0;
|
||||
}
|
||||
|
||||
char *Sys_ConsoleInput (void)
|
||||
{
|
||||
static char text[256];
|
||||
|
|
|
@ -222,11 +222,6 @@ int Sys_FileWrite (int handle, void *data, int count)
|
|||
return x;
|
||||
}
|
||||
|
||||
void Sys_mkdir (char *path)
|
||||
{
|
||||
_mkdir (path);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
===============================================================================
|
||||
|
@ -519,30 +514,6 @@ void Sys_InitFloatTime (void)
|
|||
}
|
||||
#endif
|
||||
|
||||
double Sys_DoubleTime (void)
|
||||
{
|
||||
static DWORD starttime;
|
||||
static qboolean first = true;
|
||||
DWORD now;
|
||||
double t;
|
||||
|
||||
now = timeGetTime();
|
||||
|
||||
if (first) {
|
||||
first = false;
|
||||
starttime = now;
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
if (now < starttime) // wrapped?
|
||||
return (now / 1000.0) + (LONG_MAX - starttime / 1000.0);
|
||||
|
||||
if (now - starttime == 0)
|
||||
return 0.0;
|
||||
|
||||
return (now - starttime) / 1000.0;
|
||||
}
|
||||
|
||||
char *Sys_ConsoleInput (void)
|
||||
{
|
||||
static char text[256];
|
||||
|
|
|
@ -121,11 +121,6 @@ int Sys_FileWrite (int handle, void *data, int count)
|
|||
return fwrite (data, 1, count, sys_handles[handle]);
|
||||
}
|
||||
|
||||
void Sys_mkdir (char *path)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
===============================================================================
|
||||
|
||||
|
@ -163,21 +158,6 @@ void Sys_Quit (void)
|
|||
exit (0);
|
||||
}
|
||||
|
||||
double Sys_DoubleTime (void)
|
||||
{
|
||||
double t;
|
||||
struct _timeb tstruct;
|
||||
static int starttime;
|
||||
|
||||
_ftime( &tstruct );
|
||||
|
||||
if (!starttime)
|
||||
starttime = tstruct.time;
|
||||
t = (tstruct.time-starttime) + tstruct.millitm*0.001;
|
||||
|
||||
return t;
|
||||
}
|
||||
|
||||
void Sys_Sleep (void)
|
||||
{
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue