Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

43 lines
1.1 KiB

  1. #include <private.h>
  2. BOOL FileExists(IN LPCSTR FileName,
  3. OUT PWIN32_FIND_DATA FindData) {
  4. UINT OldMode;
  5. BOOL Found;
  6. HANDLE FindHandle;
  7. OldMode = SetErrorMode(SEM_FAILCRITICALERRORS);
  8. FindHandle = FindFirstFile(FileName,FindData);
  9. if (FindHandle == INVALID_HANDLE_VALUE) {
  10. Found = FALSE;
  11. } else {
  12. FindClose(FindHandle);
  13. Found = TRUE;
  14. }
  15. SetErrorMode(OldMode);
  16. return(Found);
  17. }
  18. BOOL SourceIsNewer(IN LPSTR SourceFile,
  19. IN LPSTR TargetFile,
  20. IN BOOL fIsWin9x) {
  21. BOOL Newer;
  22. WIN32_FIND_DATA TargetInfo;
  23. WIN32_FIND_DATA SourceInfo;
  24. if ( FileExists(TargetFile,&TargetInfo) && FileExists(SourceFile,&SourceInfo) ) {
  25. Newer = !fIsWin9x
  26. ? (CompareFileTime(&SourceInfo.ftLastWriteTime,&TargetInfo.ftLastWriteTime) > 0)
  27. : (CompareFileTime(&SourceInfo.ftLastWriteTime,&TargetInfo.ftLastWriteTime) >= 0);
  28. } else {
  29. Newer = TRUE;
  30. }
  31. return(Newer);
  32. }