core/smn_filesystem.cpp
changeset 1738 cb3be0b31d99
parent 1379 6b76a3d0c58d
child 1796 db3a25745a2b
     1.1 --- a/core/smn_filesystem.cpp	Sun Dec 02 02:05:55 2007 +0000
     1.2 +++ b/core/smn_filesystem.cpp	Sun Dec 02 02:10:37 2007 +0000
     1.3 @@ -557,13 +557,6 @@
     1.4  	return 1;
     1.5  }
     1.6  
     1.7 -enum
     1.8 -{
     1.9 -	FileTime_LastAccess = 0,	/* Last access (not available on FAT) */
    1.10 -	FileTime_Created = 1,		/* Creation (not available on FAT) */
    1.11 -	FileTime_LastChange = 2,	/* Last modification */
    1.12 -};
    1.13 -
    1.14  static cell_t sm_GetFileTime(IPluginContext *pContext, const cell_t *params)
    1.15  {
    1.16  	char *name;
    1.17 @@ -574,30 +567,16 @@
    1.18  		return 0;
    1.19  	}
    1.20  
    1.21 +	time_t time_val;
    1.22  	char realpath[PLATFORM_MAX_PATH];
    1.23  	g_SourceMod.BuildPath(Path_Game, realpath, sizeof(realpath), "%s", name);
    1.24  
    1.25 -#ifdef PLATFORM_WINDOWS
    1.26 -	struct _stat s;
    1.27 -	if (_stat(realpath, &s) != 0)
    1.28 -#elif defined PLATFORM_POSIX
    1.29 -	struct stat s;
    1.30 -	if (stat(realpath, &s) != 0)
    1.31 -#endif
    1.32 +	if (!g_LibSys.FileTime(realpath, (FileTimeType)params[2], &time_val))
    1.33  	{
    1.34  		return -1;
    1.35 -	} else {
    1.36 -		if (params[2] == FileTime_LastAccess)
    1.37 -		{
    1.38 -			return (cell_t)s.st_atime;
    1.39 -		} else if (params[2] == FileTime_Created) {
    1.40 -			return (cell_t)s.st_ctime;
    1.41 -		} else if (params[2] == FileTime_LastChange) {
    1.42 -			return (cell_t)s.st_mtime;
    1.43 -		}
    1.44  	}
    1.45  
    1.46 -	return -1;
    1.47 +	return (cell_t)time_val;
    1.48  }
    1.49  
    1.50  static cell_t sm_LogToOpenFile(IPluginContext *pContext, const cell_t *params)