#include #include #include #include #include "types.h" #include "info.h" string InfoGetFileName (string path) { string t = strrchr(path, '\\'); if (t == NULL) return path; return (t + 1); } uint32 InfoGetFileSize (string path) { FILE* f = fopen (path, "r"); if (!f) return 0; fseek(f, 0, SEEK_END); uint32 ret = (uint32) ftell(f); fclose (f); return ret; } TimeSystem ConvertTimeToTimeSystem (struct tm t) { TimeSystem sys = {0,0}; uint32 year = 1900 + t.tm_year - 1; uint32 yday = t.tm_yday; sys.Time = (t.tm_hour * 3600000) + (uint32)(t.tm_min * 60000) + (uint32)(t.tm_sec * 1000); sys.Date = (yday) + (uint32)((year/4) * (365*4 + 1)) + (uint32)(year%4 * 365); return sys; } TimeSystem InfoGetTime () { time_t now = time(NULL); struct tm* t = gmtime(&now); return ConvertTimeToTimeSystem(*t); } TimeSystem InfoGetFileCreated(string file) { struct tm* time; struct stat attrib; stat(file, &attrib); time = gmtime(&(attrib.st_ctime)); if (time == NULL) return InfoGetTime(); return ConvertTimeToTimeSystem(*time); } TimeSystem InfoGetFileModified(string file) { struct tm* time; struct stat attrib; stat(file, &attrib); time = gmtime(&(attrib.st_mtime)); if (time == NULL) return InfoGetTime(); return ConvertTimeToTimeSystem(*time); }