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.

46 lines
1.3 KiB

  1. //+----------------------------------------------------------------------------
  2. //
  3. // File: fileexists.cpp
  4. //
  5. // Module: CMSETUP.LIB
  6. //
  7. // Synopsis: Implementation of the FileExists function.
  8. //
  9. // Copyright (c) 1998 Microsoft Corporation
  10. //
  11. // Author: quintinb Created Header 08/19/99
  12. //
  13. //+----------------------------------------------------------------------------
  14. #include "cmsetup.h"
  15. //+----------------------------------------------------------------------------
  16. //
  17. // Function: FileExists
  18. //
  19. // Synopsis: Helper function to encapsulate determining if a file exists.
  20. //
  21. // Arguments: LPCTSTR pszFullNameAndPath - The FULL Name and Path of the file.
  22. //
  23. // Returns: BOOL - TRUE if the file is located
  24. //
  25. // History: nickball Created 3/9/98
  26. //
  27. //+----------------------------------------------------------------------------
  28. BOOL FileExists(LPCTSTR pszFullNameAndPath)
  29. {
  30. MYDBGASSERT(pszFullNameAndPath);
  31. if (pszFullNameAndPath && pszFullNameAndPath[0])
  32. {
  33. HANDLE hFile = CreateFile(pszFullNameAndPath, 0, FILE_SHARE_READ | FILE_SHARE_WRITE,
  34. NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
  35. if (hFile != INVALID_HANDLE_VALUE)
  36. {
  37. CloseHandle(hFile);
  38. return TRUE;
  39. }
  40. }
  41. return FALSE;
  42. }