Source code of Windows XP (NT5)
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.

78 lines
1.8 KiB

  1. //+----------------------------------------------------------------------------
  2. //
  3. // Copyright (C) 1992, Microsoft Corporation.
  4. //
  5. // File: DfsRtl.c
  6. //
  7. // Contents:
  8. //
  9. // Functions: DfsRtlDeleteFile - Deletes a file given its name.
  10. // DfsRtlPrefixPath - Is one path a prefix of another?
  11. //
  12. // History: 27 May 1992 PeterCo Created.
  13. //
  14. //-----------------------------------------------------------------------------
  15. #ifdef KERNEL_MODE
  16. #include "dfsprocs.h"
  17. #include "dfsrtl.h"
  18. #define Dbg (DEBUG_TRACE_RTL)
  19. #endif
  20. #ifdef ALLOC_PRAGMA
  21. #pragma alloc_text( PAGE, DfsRtlPrefixPath )
  22. #endif // ALLOC_PRAGMA
  23. //+-------------------------------------------------------------------
  24. //
  25. // Function: DfsRtlPrefixPath, local
  26. //
  27. // Synopsis: This routine will return TRUE if the first string argument
  28. // is a path name prefix of the second string argument.
  29. //
  30. // Arguments: [Prefix] -- Pointer to target device object for
  31. // the request.
  32. // [Test] -- Pointer to I/O request packet
  33. // [IgnoreCase] -- TRUE if the comparison should be done
  34. // case-insignificant.
  35. //
  36. // Returns: BOOLEAN - TRUE if Prefix is a prefix of Test and the
  37. // comparison ends at a path separator character.
  38. //
  39. //--------------------------------------------------------------------
  40. BOOLEAN
  41. DfsRtlPrefixPath (
  42. IN PUNICODE_STRING Prefix,
  43. IN PUNICODE_STRING Test,
  44. IN BOOLEAN IgnoreCase
  45. ) {
  46. int cchPrefix;
  47. if (Prefix->Length > Test->Length) {
  48. return FALSE;
  49. }
  50. cchPrefix = Prefix->Length / sizeof (WCHAR);
  51. if (Prefix->Length < Test->Length &&
  52. Test->Buffer[cchPrefix] != L'\\') {
  53. return FALSE;
  54. }
  55. return( RtlPrefixUnicodeString( Prefix, Test, IgnoreCase ) );
  56. }