Skip to content

Instantly share code, notes, and snippets.

@mattpodwysocki
Created August 30, 2016 17:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattpodwysocki/4cf1d32784a76b6a1f6fc23d09468835 to your computer and use it in GitHub Desktop.
Save mattpodwysocki/4cf1d32784a76b6a1f6fc23d09468835 to your computer and use it in GitHub Desktop.
bool CompareLastWrite(const wchar_t* szPath1, const wchar_t* szPath2)
{
HANDLE hPath1, hPath2;
FILETIME ftPath1Create, ftPath1Access, ftPath1Write;
FILETIME ftPath2Create, ftPath2Access, ftPath2Write;
hPath1 = CreateFile2(szPath1, GENERIC_READ, FILE_SHARE_READ, OPEN_EXISTING, nullptr);
if (hPath1 == INVALID_HANDLE_VALUE && GetLastError() == ERROR_FILE_NOT_FOUND) {
return false;
}
hPath2 = CreateFile2(szPath2, GENERIC_READ, FILE_SHARE_READ, OPEN_EXISTING, nullptr);
GetFileTime(hPath1, &ftPath1Create, &ftPath1Access, &ftPath1Write);
GetFileTime(hPath2, &ftPath2Create, &ftPath2Access, &ftPath2Write);
ULARGE_INTEGER ul1;
ul1.LowPart = ftPath1Write.dwLowDateTime;
ul1.HighPart = ftPath1Write.dwHighDateTime;
ULARGE_INTEGER ul2;
ul2.LowPart = ftPath2Write.dwLowDateTime;
ul2.HighPart = ftPath2Write.dwHighDateTime;
return ul1.QuadPart > ul2.QuadPart;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment