Windows NT 4.0 source code leak
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.

77 lines
1.7 KiB

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