Moved Sys_FileTime() into common/sys_common.c

This commit is contained in:
Marcus Sundberg 2000-01-06 17:46:47 +00:00
parent 62a2ef817c
commit 3dc80e29b7
10 changed files with 40 additions and 158 deletions

View file

@ -27,6 +27,12 @@
#include <stdio.h> #include <stdio.h>
#include <stdarg.h> #include <stdarg.h>
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
#ifdef HAVE_SYS_STAT_H
# include <sys/stat.h>
#endif
int nostdout = 0; int nostdout = 0;
@ -60,3 +66,37 @@ void Sys_Printf (char *fmt, ...)
/* Make sure output is seen. */ /* Make sure output is seen. */
fflush(stdout); fflush(stdout);
} }
/*
============
Sys_FileTime
returns -1 if not present
============
*/
int Sys_FileTime (char *path)
{
int ret = -1;
#ifdef HAVE_STAT
struct stat buf;
if (stat(path, &buf) == 0) ret = buf.st_mtime;
#else /* HAVE_STAT */
FILE *f;
#if defined(_WIN32) && !defined(SERVERONLY)
int t = VID_ForceUnlockedAndReturnState();
#endif
f = fopen(path, "rb");
if (f) {
fclose(f);
ret = 1;
}
#if defined(_WIN32) && !defined(SERVERONLY)
VID_ForceLockState(t);
#endif
#endif /* HAVE_STAT */
return ret;
}

View file

@ -104,22 +104,6 @@ void Sys_Warn (char *warning, ...) {
fprintf(stderr, "Warning: %s", string); fprintf(stderr, "Warning: %s", string);
} }
/*
Sys_FileTime
returns -1 if not present
*/
int Sys_FileTime (char *path) {
struct stat buf;
if (stat (path,&buf) == -1)
return -1;
return buf.st_mtime;
}
void Sys_mkdir (char *path) { void Sys_mkdir (char *path) {
mkdir (path, 0777); mkdir (path, 0777);
} }

View file

@ -115,20 +115,6 @@ int Sys_FileWrite (int handle, void *data, int count)
return fwrite (data, 1, count, sys_handles[handle]); return fwrite (data, 1, count, sys_handles[handle]);
} }
int Sys_FileTime (char *path)
{
FILE *f;
f = fopen(path, "rb");
if (f)
{
fclose(f);
return 1;
}
return -1;
}
void Sys_mkdir (char *path) void Sys_mkdir (char *path)
{ {
} }

View file

@ -97,29 +97,6 @@ int filelength (FILE *f)
#endif #endif
int Sys_FileTime (char *path)
{
FILE *f;
int t, retval;
t = VID_ForceUnlockedAndReturnState ();
f = fopen(path, "rb");
if (f)
{
fclose(f);
retval = 1;
}
else
{
retval = -1;
}
VID_ForceLockState (t);
return retval;
}
void Sys_mkdir (char *path) void Sys_mkdir (char *path)
{ {
_mkdir (path); _mkdir (path);

View file

@ -47,24 +47,6 @@ qboolean stdin_ready;
=============================================================================== ===============================================================================
*/ */
/*
============
Sys_FileTime
returns -1 if not present
============
*/
int Sys_FileTime (char *path)
{
struct stat buf;
if (stat (path,&buf) == -1)
return -1;
return buf.st_mtime;
}
/* /*
============ ============
Sys_mkdir Sys_mkdir

View file

@ -26,25 +26,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
extern cvar_t sys_nostdout; extern cvar_t sys_nostdout;
/*
================
Sys_FileTime
================
*/
int Sys_FileTime (char *path)
{
FILE *f;
f = fopen(path, "rb");
if (f)
{
fclose(f);
return 1;
}
return -1;
}
/* /*
================ ================
Sys_mkdir Sys_mkdir

View file

@ -376,23 +376,6 @@ UpdateSbrk:
} }
/*
============
Sys_FileTime
returns -1 if not present
============
*/
int Sys_FileTime (char *path)
{
struct stat buf;
if (stat (path,&buf) == -1)
return -1;
return buf.st_mtime;
}
void Sys_mkdir (char *path) void Sys_mkdir (char *path)
{ {
mkdir (path, 0777); mkdir (path, 0777);

View file

@ -173,20 +173,6 @@ int Sys_FileWrite (int handle, void *data, int count)
return fwrite (data, 1, count, sys_handles[handle].hFile); return fwrite (data, 1, count, sys_handles[handle].hFile);
} }
int Sys_FileTime (char *path)
{
FILE *f;
f = fopen(path, "rb");
if (f)
{
fclose(f);
return 1;
}
return -1;
}
void Sys_mkdir (char *path) void Sys_mkdir (char *path)
{ {
mkdir( path, 0777 ); mkdir( path, 0777 );

View file

@ -222,29 +222,6 @@ int Sys_FileWrite (int handle, void *data, int count)
return x; return x;
} }
int Sys_FileTime (char *path)
{
FILE *f;
int t, retval;
t = VID_ForceUnlockedAndReturnState ();
f = fopen(path, "rb");
if (f)
{
fclose(f);
retval = 1;
}
else
{
retval = -1;
}
VID_ForceLockState (t);
return retval;
}
void Sys_mkdir (char *path) void Sys_mkdir (char *path)
{ {
_mkdir (path); _mkdir (path);

View file

@ -121,20 +121,6 @@ int Sys_FileWrite (int handle, void *data, int count)
return fwrite (data, 1, count, sys_handles[handle]); return fwrite (data, 1, count, sys_handles[handle]);
} }
int Sys_FileTime (char *path)
{
FILE *f;
f = fopen(path, "rb");
if (f)
{
fclose(f);
return 1;
}
return -1;
}
void Sys_mkdir (char *path) void Sys_mkdir (char *path)
{ {
} }