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.

235 lines
4.7 KiB

  1. //--------------------------------------------------------------------------
  2. //
  3. // Copyright (C) 1999, Microsoft Corporation
  4. //
  5. // File: dfspathname.cxx
  6. //
  7. //--------------------------------------------------------------------------
  8. #ifndef __DFS_PATH_NAME__
  9. #define __DFS_PATH_NAME__
  10. #include "DfsStrings.hxx"
  11. class DfsPathName
  12. {
  13. private:
  14. DfsString _PathName;
  15. DfsString _ServerName;
  16. DfsString _ShareName;
  17. DfsString _FolderName;
  18. DfsString _RemainingName;
  19. DFSSTATUS
  20. InitializePathName()
  21. {
  22. DFSSTATUS Status;
  23. UNICODE_STRING ServerName;
  24. UNICODE_STRING ShareName;
  25. UNICODE_STRING FolderName;
  26. UNICODE_STRING RemainingName;
  27. Status = DfsGetFirstComponent(GetPathCountedString(),
  28. &ServerName,
  29. &FolderName );
  30. if (Status == ERROR_SUCCESS)
  31. {
  32. Status = DfsGetPathComponents(GetPathCountedString(),
  33. &ServerName,
  34. &ShareName,
  35. &RemainingName );
  36. }
  37. if (Status == ERROR_SUCCESS)
  38. {
  39. Status = _ServerName.CreateString(&ServerName);
  40. }
  41. if (Status == ERROR_SUCCESS)
  42. {
  43. Status = _ShareName.CreateString(&ShareName);
  44. }
  45. if (Status == ERROR_SUCCESS)
  46. {
  47. Status = _FolderName.SetStringToPointer(&FolderName);
  48. }
  49. if (Status == ERROR_SUCCESS)
  50. {
  51. _RemainingName.SetStringToPointer(&RemainingName);
  52. }
  53. return Status;
  54. }
  55. public:
  56. DfsPathName()
  57. {
  58. NOTHING;
  59. }
  60. BOOLEAN
  61. IsEmptyPath()
  62. {
  63. PUNICODE_STRING pPath = GetPathCountedString();
  64. return (pPath->Length == 0);
  65. }
  66. LPWSTR
  67. GetPathString()
  68. {
  69. return _PathName.GetString();
  70. }
  71. LPWSTR
  72. GetServerString()
  73. {
  74. return _ServerName.GetString();
  75. }
  76. LPWSTR
  77. GetShareString()
  78. {
  79. return _ShareName.GetString();
  80. }
  81. LPWSTR
  82. GetFolderString()
  83. {
  84. return _FolderName.GetString();
  85. }
  86. LPWSTR
  87. GetRemainingString()
  88. {
  89. return _RemainingName.GetString();
  90. }
  91. PUNICODE_STRING
  92. GetPathCountedString()
  93. {
  94. return _PathName.GetCountedString();
  95. }
  96. PUNICODE_STRING
  97. GetServerCountedString()
  98. {
  99. return _ServerName.GetCountedString();
  100. }
  101. PUNICODE_STRING
  102. GetShareCountedString()
  103. {
  104. return _ShareName.GetCountedString();
  105. }
  106. PUNICODE_STRING
  107. GetFolderCountedString()
  108. {
  109. return _FolderName.GetCountedString();
  110. }
  111. PUNICODE_STRING
  112. GetRemainingCountedString()
  113. {
  114. return _RemainingName.GetCountedString();
  115. }
  116. DfsString *
  117. GetPathDfsString()
  118. {
  119. return &_PathName;
  120. }
  121. DfsString *
  122. GetServerDfsString()
  123. {
  124. return &_ServerName;
  125. }
  126. DfsString *
  127. GetShareDfsString()
  128. {
  129. return &_ShareName;
  130. }
  131. DfsString *
  132. GetFolderDfsString()
  133. {
  134. return &_FolderName;
  135. }
  136. DfsString *
  137. GetRemainingDfsString()
  138. {
  139. return &_RemainingName;
  140. }
  141. DFSSTATUS
  142. CreatePathName(IN LPWSTR InString)
  143. {
  144. DFSSTATUS Status = ERROR_SUCCESS;
  145. Status = _PathName.CreateString(InString);
  146. if (Status == ERROR_SUCCESS)
  147. {
  148. Status = InitializePathName();
  149. }
  150. return Status;
  151. }
  152. DFSSTATUS
  153. CreatePathName(IN PUNICODE_STRING pUnicode)
  154. {
  155. DFSSTATUS Status = ERROR_SUCCESS;
  156. Status = _PathName.CreateString(pUnicode);
  157. if (Status == ERROR_SUCCESS)
  158. {
  159. Status = InitializePathName();
  160. }
  161. return Status;
  162. }
  163. DFSSTATUS
  164. SetPathName(LPWSTR ServerName, LPWSTR ShareName, ULONG PathSeps = 2)
  165. {
  166. UNICODE_STRING Path;
  167. DFSSTATUS Status;
  168. Status = DfsCreateUnicodePathString( &Path,
  169. PathSeps,
  170. ServerName,
  171. ShareName);
  172. if (Status == ERROR_SUCCESS)
  173. {
  174. Status = _PathName.SetStringToPointer(&Path);
  175. if (Status == ERROR_SUCCESS)
  176. {
  177. Status = InitializePathName();
  178. }
  179. }
  180. return Status;
  181. }
  182. ~DfsPathName()
  183. {
  184. NOTHING;
  185. }
  186. };
  187. #endif // __DFS_PATH_NAME