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.

82 lines
2.1 KiB

  1. //+----------------------------------------------------------------------------
  2. //
  3. // Scheduling Agent Service
  4. //
  5. // Microsoft Windows
  6. // Copyright (C) Microsoft Corporation, 1992 - 1996.
  7. //
  8. // File: path.cxx
  9. //
  10. // Contents: Functions to manipulate file path strings
  11. //
  12. // History: 02-Jul-96 EricB created
  13. //
  14. //-----------------------------------------------------------------------------
  15. #include "..\pch\headers.hxx"
  16. #pragma hdrstop
  17. #include "svc_core.hxx"
  18. #include "..\inc\resource.h"
  19. #include "path.hxx"
  20. //+----------------------------------------------------------------------------
  21. //
  22. // Function: OnExtList
  23. //
  24. //-----------------------------------------------------------------------------
  25. BOOL
  26. OnExtList(LPCWSTR pszExtList, LPCWSTR pszExt)
  27. {
  28. for (; *pszExtList; pszExtList += lstrlen(pszExtList) + 1)
  29. {
  30. if (!lstrcmpi(pszExt, pszExtList))
  31. {
  32. return TRUE; // yes
  33. }
  34. }
  35. return FALSE;
  36. }
  37. // Character offset where binary exe extensions begin in above
  38. #define BINARY_EXE_OFFSET 15
  39. #define EXT_TABLE_SIZE 26 // Understand line above before changing
  40. static const WCHAR achExes[EXT_TABLE_SIZE] = L".cmd\0.bat\0.pif\0.exe\0.com\0";
  41. //+----------------------------------------------------------------------------
  42. //
  43. // Function:
  44. //
  45. // Synopsis:
  46. //
  47. // Arguments: [] -
  48. //
  49. //-----------------------------------------------------------------------------
  50. BOOL WINAPI
  51. PathIsBinaryExe(LPCWSTR szFile)
  52. {
  53. Win4Assert( szFile );
  54. return OnExtList(achExes+BINARY_EXE_OFFSET, PathFindExtension(szFile));
  55. }
  56. //+----------------------------------------------------------------------------
  57. //
  58. // Function: PathIsExe
  59. //
  60. // Synopsis: Determine if a path is a program by looking at the extension
  61. //
  62. // Arguments: [szFile] - the path name.
  63. //
  64. // Returns: TRUE if it is a program, FALSE otherwise.
  65. //
  66. //-----------------------------------------------------------------------------
  67. BOOL WINAPI
  68. PathIsExe(LPCWSTR szFile)
  69. {
  70. LPCWSTR temp = PathFindExtension(szFile);
  71. Win4Assert( temp );
  72. return OnExtList(achExes, temp);
  73. }