1.1 --- a/core/systems/LibrarySys.cpp Sun Dec 02 02:05:55 2007 +0000
1.2 +++ b/core/systems/LibrarySys.cpp Sun Dec 02 02:10:37 2007 +0000
1.3 @@ -29,6 +29,7 @@
1.4 * Version: $Id$
1.5 */
1.6
1.7 +#include <sys/stat.h>
1.8 #include <stdio.h>
1.9 #include <stdarg.h>
1.10 #include <string.h>
1.11 @@ -396,3 +397,32 @@
1.12 /* We scanned and found no path separator */
1.13 return UTIL_Format(buffer, maxlength, "%s", path);
1.14 }
1.15 +
1.16 +bool LibrarySystem::FileTime(const char *path, FileTimeType type, time_t *pTime)
1.17 +{
1.18 +#ifdef PLATFORM_WINDOWS
1.19 + struct _stat s;
1.20 + if (_stat(path, &s) != 0)
1.21 +#elif defined PLATFORM_POSIX
1.22 + struct stat s;
1.23 + if (stat(path, &s) != 0)
1.24 +#endif
1.25 + {
1.26 + return false;
1.27 + }
1.28 +
1.29 + if (type == FileTime_LastAccess)
1.30 + {
1.31 + *pTime = s.st_atime;
1.32 + }
1.33 + else if (type == FileTime_Created)
1.34 + {
1.35 + *pTime = s.st_ctime;
1.36 + }
1.37 + else if (type == FileTime_LastChange)
1.38 + {
1.39 + *pTime = s.st_mtime;
1.40 + }
1.41 +
1.42 + return true;
1.43 +}