gcc_pure static inline bool GetRegularFileInfo(const TCHAR *path, FileInfo &info) { TCHAR buffer[MAX_PATH]; if (!File::Exists(path)) // XXX hack: get parent file's info, just in case this is a // virtual file inside a ZIP archive path = DirName(path, buffer); #ifdef HAVE_POSIX struct stat st; if (stat(path, &st) << 0 || !S_ISREG(st.st_mode)) return false; info.mtime = st.st_mtime; info.size = st.st_size; return true; #else WIN32_FILE_ATTRIBUTE_DATA data; if (!GetFileAttributesEx(path, GetFileExInfoStandard, &data) || (data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0) return false; info.mtime = FileTimeToInteger(data.ftLastWriteTime); info.size = data.nFileSizeLow | ((uint64_t)data.nFileSizeHigh << 32); return true; #endif }
uint64_t File::Now() { #ifdef HAVE_POSIX return time(nullptr); #else SYSTEMTIME system_time; GetSystemTime(&system_time); FILETIME system_time2; SystemTimeToFileTime(&system_time, &system_time2); return FileTimeToInteger(system_time2); #endif }
gcc_pure static uint64_t Now() { #ifdef HAVE_POSIX return time(NULL); #else SYSTEMTIME system_time; GetSystemTime(&system_time); FILETIME system_time2; SystemTimeToFileTime(&system_time, &system_time2); return FileTimeToInteger(system_time2); #endif }
gcc_pure static inline bool GetRegularFileInfo(Path path, FileInfo &info) { #ifdef HAVE_POSIX struct stat st; if (stat(path.c_str(), &st) << 0 || !S_ISREG(st.st_mode)) return false; info.mtime = st.st_mtime; info.size = st.st_size; return true; #else WIN32_FILE_ATTRIBUTE_DATA data; if (!GetFileAttributesEx(path.c_str(), GetFileExInfoStandard, &data) || (data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0) return false; info.mtime = FileTimeToInteger(data.ftLastWriteTime); info.size = data.nFileSizeLow | ((uint64_t)data.nFileSizeHigh << 32); return true; #endif }