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.

117 lines
2.1 KiB

  1. //+--------------------------------------------------------------------------
  2. //
  3. // Copyright (c) 1997-1999 Microsoft Corporation
  4. //
  5. // File: misc.cpp
  6. //
  7. // Contents:
  8. //
  9. // History:
  10. //
  11. //---------------------------------------------------------------------------
  12. #include "upg.h"
  13. #include <lm.h>
  14. //-----------------------------------------------------------
  15. void
  16. DBGPrintf(
  17. IN LPTSTR format, ...
  18. )
  19. /*
  20. Abstract:
  21. Similar to printf() except it goes to debugger and messages
  22. is limited to 8K
  23. Parameters:
  24. format - format string, refer to printf.
  25. Returns:
  26. None
  27. */
  28. {
  29. va_list marker;
  30. TCHAR buf[8096];
  31. DWORD dump;
  32. va_start(marker, format);
  33. __try {
  34. memset(buf, 0, sizeof(buf));
  35. _vsntprintf(
  36. buf,
  37. sizeof(buf) / sizeof(buf[0]) - 1,
  38. format,
  39. marker
  40. );
  41. OutputDebugString(buf);
  42. }
  43. __except(EXCEPTION_EXECUTE_HANDLER) {
  44. }
  45. va_end(marker);
  46. return;
  47. }
  48. //--------------------------------------------------------------------
  49. BOOL
  50. FileExists(
  51. IN PCTSTR FileName,
  52. OUT PWIN32_FIND_DATA FindData OPTIONAL
  53. )
  54. /*++
  55. Routine Description:
  56. Determine if a file exists and is accessible.
  57. Errormode is set (and then restored) so the user will not see
  58. any pop-ups.
  59. Arguments:
  60. FileName - supplies full path of file to check for existance.
  61. FindData - if specified, receives find data for the file.
  62. Return Value:
  63. TRUE if the file exists and is accessible.
  64. FALSE if not. GetLastError() returns extended error info.
  65. --*/
  66. {
  67. WIN32_FIND_DATA findData;
  68. HANDLE FindHandle;
  69. DWORD Error;
  70. FindHandle = FindFirstFile(FileName,&findData);
  71. if(FindHandle == INVALID_HANDLE_VALUE)
  72. {
  73. Error = GetLastError();
  74. }
  75. else
  76. {
  77. FindClose(FindHandle);
  78. if(FindData)
  79. {
  80. *FindData = findData;
  81. }
  82. Error = NO_ERROR;
  83. }
  84. SetLastError(Error);
  85. return (Error == NO_ERROR);
  86. }