int64_t omrfile_lastmod(struct OMRPortLibrary *portLibrary, const char *path) { int64_t result = -1; wchar_t unicodeBuffer[UNICODE_BUFFER_SIZE], *unicodePath; Trc_PRT_file_lastmod_Entry(path); /* Convert the filename from UTF8 to Unicode */ unicodePath = file_get_unicode_path(portLibrary, path, unicodeBuffer, UNICODE_BUFFER_SIZE); if (NULL != unicodePath) { WIN32_FILE_ATTRIBUTE_DATA myStat; if (0 == GetFileAttributesExW(unicodePath, GetFileExInfoStandard, &myStat)) { int32_t error = GetLastError(); result = portLibrary->error_set_last_error(portLibrary, error, findError(error)); } else { /* * Search MSDN for 'Converting a time_t Value to a File Time' for following implementation. */ result = ((int64_t) myStat.ftLastWriteTime.dwHighDateTime << 32) | (int64_t) myStat.ftLastWriteTime.dwLowDateTime; result = (result - 116444736000000000) / 10000; } if (unicodeBuffer != unicodePath) { portLibrary->mem_free_memory(portLibrary, unicodePath); } } Trc_PRT_file_lastmod_Exit(result); return result; }
int64_t omrfile_lastmod(struct OMRPortLibrary *portLibrary, const char *path) { struct stat st; Trc_PRT_file_lastmod_Entry(path); tzset(); /* Neutrino does not handle NULL for stat */ if (0 != stat(path, &st)) { Trc_PRT_file_lastmod_Exit(-1); return -1; } Trc_PRT_file_lastmod_Exit(st.st_mtime); return st.st_mtime; }