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.

839 lines
19 KiB

  1. /*++
  2. 1998 Seagate Software, Inc. All rights reserved.
  3. Module Name:
  4. SegmentRecord.cpp
  5. Abstract:
  6. This component is an object representation of the HSM Metadata segment record. It
  7. is both a persistable and collectable.
  8. Author:
  9. Cat Brant [cbrant] 12-Nov-1996
  10. Revision History:
  11. --*/
  12. #include "stdafx.h"
  13. #include "metaint.h"
  14. #include "metalib.h"
  15. #include "SegRec.h"
  16. #undef WSB_TRACE_IS
  17. #define WSB_TRACE_IS WSB_TRACE_BIT_META
  18. #define SEG_KEY_TYPE 1
  19. static USHORT iCountSegrec = 0;
  20. HRESULT
  21. CSegRec::GetSegmentRecord(
  22. OUT GUID *pBagId,
  23. OUT LONGLONG *pSegStartLoc,
  24. OUT LONGLONG *pSegLen,
  25. OUT USHORT *pSegFlags,
  26. OUT GUID *pPrimPos,
  27. OUT LONGLONG *pSecPos
  28. )
  29. /*++
  30. Routine Description:
  31. See ISegRec::GetSegmentRecord
  32. Arguments:
  33. See ISegRec::GetSegmentRecord
  34. Return Value:
  35. See ISegRec::GetSegmentRecord
  36. --*/
  37. {
  38. HRESULT hr = S_OK;
  39. WsbTraceIn(OLESTR("CSegRec::GetSegmentRecord"),OLESTR(""));
  40. try {
  41. //Make sure we can provide data memebers
  42. WsbAssert(0 != pBagId, E_POINTER);
  43. WsbAssert(0 != pSegStartLoc, E_POINTER);
  44. WsbAssert(0 != pSegLen, E_POINTER);
  45. WsbAssert(0 != pSegFlags, E_POINTER);
  46. WsbAssert(0 != pPrimPos, E_POINTER);
  47. WsbAssert(0 != pSecPos, E_POINTER);
  48. //Provide the data members
  49. *pBagId = m_BagId;
  50. *pSegStartLoc = m_SegStartLoc;
  51. *pSegLen = m_SegLen;
  52. *pSegFlags = m_SegFlags;
  53. *pPrimPos = m_PrimPos;
  54. *pSecPos = m_SecPos;
  55. } WsbCatch(hr);
  56. WsbTraceOut(OLESTR("CSegRec::GetSegmentRecord"),
  57. OLESTR("hr = <%ls>, BagId = <%ls>, SegStartLoc = <%ls>, SegLen = <%ls>, SegFlags = <%ls>, PrimPos = <%ls>, SecPos = <%ls>"),
  58. WsbHrAsString(hr), WsbPtrToGuidAsString(pBagId),
  59. WsbStringCopy(WsbPtrToLonglongAsString(pSegStartLoc)),
  60. WsbStringCopy(WsbPtrToLonglongAsString(pSegLen)),
  61. WsbStringCopy(WsbPtrToUshortAsString(pSegFlags)),
  62. WsbStringCopy(WsbPtrToGuidAsString(pPrimPos)),
  63. WsbStringCopy(WsbPtrToLonglongAsString(pSecPos)));
  64. return(hr);
  65. }
  66. HRESULT
  67. CSegRec::FinalConstruct(
  68. void
  69. )
  70. /*++
  71. Routine Description:
  72. This method does some initialization of the object that is necessary
  73. after construction.
  74. Arguments:
  75. None.
  76. Return Value:
  77. S_OK
  78. Anything returned by CWsbCollectable::FinalConstruct().
  79. --*/
  80. {
  81. HRESULT hr = S_OK;
  82. WsbTraceIn(OLESTR("CSegRec::FinalConstruct"), OLESTR(""));
  83. try {
  84. WsbAssertHr(CWsbDbEntity::FinalConstruct());
  85. m_BagId = GUID_NULL;
  86. m_SegStartLoc = 0;
  87. m_SegLen = 0;
  88. m_SegFlags = 0;
  89. m_PrimPos = GUID_NULL;
  90. m_SecPos = 0;
  91. } WsbCatch(hr);
  92. iCountSegrec++;
  93. WsbTraceOut(OLESTR("CSegRec::FinalConstruct"), OLESTR("hr = <%ls>, Count is <%d>"),
  94. WsbHrAsString(hr), iCountSegrec);
  95. return(hr);
  96. }
  97. void
  98. CSegRec::FinalRelease(
  99. void
  100. )
  101. /*++
  102. Implements:
  103. CSegRec::FinalRelease().
  104. --*/
  105. {
  106. WsbTraceIn(OLESTR("CSegRec::FinalRelease"), OLESTR(""));
  107. CWsbDbEntity::FinalRelease();
  108. iCountSegrec--;
  109. WsbTraceOut(OLESTR("CSegRec::FinalRelease"), OLESTR("Count is <%d>"), iCountSegrec);
  110. }
  111. HRESULT CSegRec::GetClassID
  112. (
  113. OUT LPCLSID pclsid
  114. )
  115. /*++
  116. Routine Description:
  117. See IPerist::GetClassID()
  118. Arguments:
  119. See IPerist::GetClassID()
  120. Return Value:
  121. See IPerist::GetClassID()
  122. --*/
  123. {
  124. HRESULT hr = S_OK;
  125. WsbTraceIn(OLESTR("CSegRec::GetClassID"), OLESTR(""));
  126. try {
  127. WsbAssert(0 != pclsid, E_POINTER);
  128. *pclsid = CLSID_CSegRec;
  129. } WsbCatch(hr);
  130. WsbTraceOut(OLESTR("CSecRec::GetClassID"), OLESTR("hr = <%ls>, CLSID = <%ls>"), WsbHrAsString(hr), WsbGuidAsString(*pclsid));
  131. return(hr);
  132. }
  133. HRESULT CSegRec::GetSizeMax
  134. (
  135. OUT ULARGE_INTEGER* pcbSize
  136. )
  137. /*++
  138. Routine Description:
  139. See IPersistStream::GetSizeMax().
  140. Arguments:
  141. See IPersistStream::GetSizeMax().
  142. Return Value:
  143. See IPersistStream::GetSizeMax().
  144. --*/
  145. {
  146. HRESULT hr = S_OK;
  147. WsbTraceIn(OLESTR("CSegRec::GetSizeMax"), OLESTR(""));
  148. try {
  149. WsbAssert(0 != pcbSize, E_POINTER);
  150. pcbSize->QuadPart = WsbPersistSizeOf(GUID) + WsbPersistSizeOf(LONGLONG) +
  151. WsbPersistSizeOf(LONGLONG) + WsbPersistSizeOf(USHORT) +
  152. WsbPersistSizeOf(GUID) + WsbPersistSizeOf(LONGLONG);
  153. // pcbSize->QuadPart = WsbPersistSizeOf(CSegRec); //???????
  154. } WsbCatch(hr);
  155. WsbTraceOut(OLESTR("CSegRec::GetSizeMax"),
  156. OLESTR("hr = <%ls>, Size = <%ls>"), WsbHrAsString(hr),
  157. WsbPtrToUliAsString(pcbSize));
  158. return(hr);
  159. }
  160. HRESULT CSegRec::Load
  161. (
  162. IN IStream* pStream
  163. )
  164. /*++
  165. Routine Description:
  166. See IPersistStream::Load().
  167. Arguments:
  168. See IPersistStream::Load().
  169. Return Value:
  170. See IPersistStream::Load().
  171. --*/
  172. {
  173. HRESULT hr = S_OK;
  174. WsbTraceIn(OLESTR("CSegRec::Load"), OLESTR(""));
  175. try {
  176. WsbAssert(0 != pStream, E_POINTER);
  177. WsbAffirmHr(WsbLoadFromStream(pStream, &m_BagId));
  178. WsbAffirmHr(WsbLoadFromStream(pStream, &m_SegStartLoc));
  179. WsbAffirmHr(WsbLoadFromStream(pStream, &m_SegLen));
  180. WsbAffirmHr(WsbLoadFromStream(pStream, &m_SegFlags));
  181. WsbAffirmHr(WsbLoadFromStream(pStream, &m_PrimPos));
  182. WsbAffirmHr(WsbLoadFromStream(pStream, &m_SecPos));
  183. } WsbCatch(hr);
  184. WsbTraceOut(OLESTR("CSegRec::Load"),
  185. OLESTR("hr = <%ls>, GUID = <%ls>, SegStartLoc = <%I64u>, SegLen = <%I64u>, SegFlags = <%u>, PrimPos <%ls>, SecPos = <%I64u>"),
  186. WsbStringCopy(WsbHrAsString(hr)),
  187. WsbGuidAsString(m_BagId),
  188. m_SegStartLoc, m_SegLen, m_SegFlags, WsbStringCopy(WsbGuidAsString(m_PrimPos)), m_SecPos);
  189. return(hr);
  190. }
  191. HRESULT CSegRec::Save
  192. (
  193. IN IStream* pStream,
  194. IN BOOL clearDirty
  195. )
  196. /*++
  197. Routine Description:
  198. See IPersistStream::Save().
  199. Arguments:
  200. See IPersistStream::Save().
  201. Return Value:
  202. See IPersistStream::Save().
  203. --*/
  204. {
  205. HRESULT hr = S_OK;
  206. WsbTraceIn(OLESTR("CSegRec::Save"), OLESTR("clearDirty = <%ls>"), WsbBoolAsString(clearDirty));
  207. try {
  208. WsbAssert(0 != pStream, E_POINTER);
  209. WsbAffirmHr(WsbSaveToStream(pStream, m_BagId));
  210. WsbAffirmHr(WsbSaveToStream(pStream, m_SegStartLoc));
  211. WsbAffirmHr(WsbSaveToStream(pStream, m_SegLen));
  212. WsbAffirmHr(WsbSaveToStream(pStream, m_SegFlags));
  213. WsbAffirmHr(WsbSaveToStream(pStream, m_PrimPos));
  214. WsbAffirmHr(WsbSaveToStream(pStream, m_SecPos));
  215. // If we got it saved and we were asked to clear the dirty bit, then
  216. // do so now.
  217. if (clearDirty) {
  218. m_isDirty = FALSE;
  219. }
  220. } WsbCatch(hr);
  221. WsbTraceOut(OLESTR("CSegRec::Save"), OLESTR("hr = <%ls>"), WsbHrAsString(hr));
  222. return(hr);
  223. }
  224. HRESULT
  225. CSegRec::SetSegmentRecord
  226. (
  227. IN GUID BagId,
  228. IN LONGLONG SegStartLoc,
  229. IN LONGLONG SegLen,
  230. IN USHORT SegFlags,
  231. IN GUID PrimPos,
  232. IN LONGLONG SecPos
  233. )
  234. /*++
  235. Routine Description:
  236. See ISegRec::Set().
  237. Arguments:
  238. See ISegRec::Set().
  239. Return Value:
  240. S_OK - Success.
  241. --*/
  242. {
  243. HRESULT hr = S_OK;
  244. WsbTraceIn(OLESTR("CSegRec::SetSegmentRecord"),
  245. OLESTR("GUID = <%ls>, SegStartLoc = <%I64u>, SegLen = <%I64u>, SegFlags = <%X>, PrimPos = <%ls>, SecPos = <%I64u>"),
  246. WsbStringCopy(WsbGuidAsString(BagId)), SegStartLoc, SegLen, SegFlags,
  247. WsbStringCopy(WsbGuidAsString(PrimPos)), SecPos);
  248. m_isDirty = TRUE;
  249. m_BagId = BagId;
  250. m_SegStartLoc = SegStartLoc;
  251. m_SegLen = SegLen;
  252. m_SegFlags = SegFlags;
  253. m_PrimPos = PrimPos;
  254. m_SecPos = SecPos;
  255. WsbTraceOut(OLESTR("CSegRec::SetSegmentRecord"), OLESTR("hr = <%ls>"),
  256. WsbHrAsString(S_OK));
  257. return(hr);
  258. }
  259. HRESULT
  260. CSegRec::GetSegmentFlags(
  261. USHORT *pSegFlags
  262. )
  263. /*++
  264. Implements:
  265. ISegRec::GetSegmentFlags().
  266. --*/
  267. {
  268. HRESULT hr = S_OK;
  269. try {
  270. WsbAssert(0 != pSegFlags, E_POINTER);
  271. *pSegFlags = m_SegFlags;
  272. } WsbCatch(hr);
  273. return(hr);
  274. }
  275. HRESULT
  276. CSegRec::SetSegmentFlags(
  277. USHORT SegFlags
  278. )
  279. /*++
  280. Implements:
  281. ISegRec::SetSegmentFlags().
  282. --*/
  283. {
  284. HRESULT hr = S_OK;
  285. m_SegFlags = SegFlags;
  286. return(hr);
  287. }
  288. HRESULT
  289. CSegRec::GetPrimPos(
  290. GUID *pPrimPos
  291. )
  292. /*++
  293. Implements:
  294. ISegRec::GetPrimPos().
  295. --*/
  296. {
  297. HRESULT hr = S_OK;
  298. try {
  299. WsbAssert(0 != pPrimPos, E_POINTER);
  300. *pPrimPos = m_PrimPos;
  301. } WsbCatch(hr);
  302. return(hr);
  303. }
  304. HRESULT
  305. CSegRec::SetPrimPos(
  306. GUID PrimPos
  307. )
  308. /*++
  309. Implements:
  310. ISegRec::SetPrimPos().
  311. --*/
  312. {
  313. HRESULT hr = S_OK;
  314. m_PrimPos = PrimPos;
  315. return(hr);
  316. }
  317. HRESULT
  318. CSegRec::GetSecPos(
  319. LONGLONG *pSecPos
  320. )
  321. /*++
  322. Implements:
  323. ISegRec::GetSecPos().
  324. --*/
  325. {
  326. HRESULT hr = S_OK;
  327. try {
  328. WsbAssert(0 != pSecPos, E_POINTER);
  329. *pSecPos = m_SecPos;
  330. } WsbCatch(hr);
  331. return(hr);
  332. }
  333. HRESULT
  334. CSegRec::SetSecPos(
  335. LONGLONG SecPos
  336. )
  337. /*++
  338. Implements:
  339. ISegRec::SetSecPos().
  340. --*/
  341. {
  342. HRESULT hr = S_OK;
  343. m_SecPos = SecPos;
  344. return(hr);
  345. }
  346. HRESULT
  347. CSegRec::Test
  348. (
  349. OUT USHORT *pTestsPassed,
  350. OUT USHORT *pTestsFailed
  351. )
  352. /*++
  353. Routine Description:
  354. See IWsbTestable::Test().
  355. Arguments:
  356. See IWsbTestable::Test().
  357. Return Value:
  358. See IWsbTestable::Test().
  359. --*/
  360. {
  361. #if 0
  362. HRESULT hr = S_OK;
  363. CComPtr<ISegRec> pSegment1;
  364. CComPtr<ISegRec> pSegment2;
  365. GUID l_BagId;
  366. LONGLONG l_SegStartLoc;
  367. LONGLONG l_SegLen;
  368. USHORT l_SegFlags;
  369. GUID l_PrimPos;
  370. LONGLONG l_SecPos;
  371. WsbTraceIn(OLESTR("CSegRec::Test"), OLESTR(""));
  372. *pTestsPassed = *pTestsFailed = 0;
  373. try {
  374. // Get the pSegment interface.
  375. WsbAssertHr(((IUnknown*)(ISegRec*) this)->QueryInterface(IID_ISegRec,
  376. (void**) &pSegment1));
  377. try {
  378. // Set the Segment to a value, and see if it is returned.
  379. WsbAssertHr(pSegment1->SetSegmentRecord(CLSID_CSegRec, 0, 6, 0, CLSID_CSegRec,0 ));
  380. WsbAssertHr(pSegment1->GetSegmentRecord(&l_BagId, &l_SegStartLoc, &l_SegLen, &l_SegFlags, &l_PrimPos, &l_SecPos));
  381. WsbAssert((l_BagId == CLSID_CSegRec) && (l_SegStartLoc == 0) &&
  382. (l_SegLen == 6) && (l_SegFlags == 0) && (l_PrimPos == CLSID_CSegRec) &&
  383. (l_SecPos == 0), E_FAIL);
  384. } WsbCatch(hr);
  385. if (hr == S_OK) {
  386. (*pTestsPassed)++;
  387. } else {
  388. (*pTestsFailed)++;
  389. }
  390. hr = S_OK;
  391. try {
  392. //Create another instance and test the comparisson methods:
  393. WsbAssertHr(CoCreateInstance(CLSID_CSegRec, NULL, CLSCTX_ALL, IID_ISegRec, (void**) &pSegment2));
  394. // Check the default values.
  395. WsbAssertHr(pSegment2->GetSegmentRecord(&l_BagId, &l_SegStartLoc, &l_SegLen, &l_SegFlags, &l_PrimPos, &l_SecPos));
  396. WsbAssert(((l_BagId == GUID_NULL) && (l_SegStartLoc == 0) && (l_SegLen == 0) &&
  397. (l_SegFlags == 0) && (l_PrimPos == GUID_NULL) && (l_SecPos == 0)), E_FAIL);
  398. } WsbCatch(hr);
  399. if (hr == S_OK) {
  400. (*pTestsPassed)++;
  401. } else {
  402. (*pTestsFailed)++;
  403. }
  404. #ifdef OLD_CODE
  405. hr = S_OK;
  406. try {
  407. // Equal
  408. WsbAssertHr(pSegment1->SetSegmentRecord(CLSID_CWsbBool, 1, 100, 0, CLSID_CWsbBool,0 ));
  409. WsbAssertHr(pSegment2->SetSegmentRecord(CLSID_CWsbBool, 1, 100, 0, CLSID_CWsbBool,0 ));
  410. WsbAssertHr(pSegment1->CompareToISegmentRecord(pSegment2, &result));
  411. } WsbCatch(hr);
  412. if (hr == S_OK) {
  413. (*pTestsPassed)++;
  414. } else {
  415. (*pTestsFailed)++;
  416. }
  417. hr = S_OK;
  418. try {
  419. WsbAssertHr(pSegment1->SetSegmentRecord(CLSID_CWsbBool, 5, 6, 3, CLSID_CWsbBool,1 ));
  420. WsbAssertHr(pSegment2->SetSegmentRecord(CLSID_CWsbLong, 0, 6, 0, CLSID_CWsbBool,0 ));
  421. WsbAssert((pSegment1->CompareToISegmentRecord(pSegment2, &result) == S_FALSE), E_FAIL);
  422. } WsbCatch(hr);
  423. if (hr == S_OK) {
  424. (*pTestsPassed)++;
  425. } else {
  426. (*pTestsFailed)++;
  427. }
  428. hr = S_OK;
  429. try {
  430. // CompareTo()
  431. WsbAssertHr(pSegment1->SetSegmentRecord(CLSID_CWsbBool, 1, 100, 0, CLSID_CWsbBool,0 ));
  432. WsbAssertHr(pSegment2->SetSegmentRecord(CLSID_CWsbBool, 10, 6, 0, CLSID_CWsbBool,0 ));
  433. WsbAssert((pSegment1->CompareToISegmentRecord(pSegment2, &result) == S_FALSE), E_FAIL);
  434. } WsbCatch(hr);
  435. if (hr == S_OK) {
  436. (*pTestsPassed)++;
  437. } else {
  438. (*pTestsFailed)++;
  439. }
  440. hr = S_OK;
  441. try {
  442. WsbAssertHr(pSegment1->SetSegmentRecord(CLSID_CWsbBool, 0, 6, 0, CLSID_CWsbBool,0 ));
  443. WsbAssertHr(pSegment2->SetSegmentRecord(CLSID_CWsbLong, 0, 6, 0, CLSID_CWsbBool,0 ));
  444. WsbAssert(((pSegment1->CompareToISegmentRecord(pSegment2, &result) == S_FALSE) && (result > 0)), E_FAIL);
  445. } WsbCatch(hr);
  446. if (hr == S_OK) {
  447. (*pTestsPassed)++;
  448. } else {
  449. (*pTestsFailed)++;
  450. }
  451. hr = S_OK;
  452. try {
  453. WsbAssertHr(pSegment1->SetSegmentRecord(CLSID_CWsbBool, 0, 6, 0, CLSID_CWsbBool,0 ));
  454. WsbAssertHr(pSegment2->SetSegmentRecord(CLSID_CWsbBool, 0, 6, 0, CLSID_CWsbBool,0 ));
  455. WsbAssert((pSegment1->CompareToISegmentRecord(pSegment2, &result) == S_OK), E_FAIL);
  456. } WsbCatch(hr);
  457. if (hr == S_OK) {
  458. (*pTestsPassed)++;
  459. } else {
  460. (*pTestsFailed)++;
  461. }
  462. try {
  463. // Try out the persistence stuff.
  464. CComPtr<IPersistFile> pFile1;
  465. CComPtr<IPersistFile> pFile2;
  466. WsbAssertHr(pSegment1->QueryInterface(IID_IPersistFile, (void**) &pFile1));
  467. WsbAssertHr(pSegment2->QueryInterface(IID_IPersistFile, (void**) &pFile2));
  468. LPOLESTR szTmp = NULL;
  469. // The item should be dirty.
  470. try {
  471. WsbAssertHr(pSegment2->SetSegmentRecord(CLSID_CWsbLong, 0, 6, 0, CLSID_CWsbBool,0 ));
  472. WsbAssertHr(pFile2->IsDirty());
  473. } WsbCatch(hr);
  474. if (hr == S_OK) {
  475. (*pTestsPassed)++;
  476. } else {
  477. (*pTestsFailed)++;
  478. }
  479. hr = S_OK;
  480. try {
  481. // Save the item, and remember.
  482. WsbAssertHr(pFile2->Save(OLESTR("c:\\WsbTests\\WsbSegment.tst"), TRUE));
  483. } WsbCatch(hr);
  484. if (hr == S_OK) {
  485. (*pTestsPassed)++;
  486. } else {
  487. (*pTestsFailed)++;
  488. }
  489. hr = S_OK;
  490. try {
  491. // It shouldn't be dirty.
  492. WsbAssert((pFile2->IsDirty() == S_FALSE), E_FAIL);
  493. } WsbCatch(hr);
  494. if (hr == S_OK) {
  495. (*pTestsPassed)++;
  496. } else {
  497. (*pTestsFailed)++;
  498. }
  499. hr = S_OK;
  500. try {
  501. // Try reading it in to another object.
  502. WsbAssertHr(pSegment1->SetSegmentRecord(CLSID_CWsbLong, 0, 6, 0, CLSID_CWsbBool,0 ));
  503. WsbAssertHr(pFile1->Load(OLESTR("c:\\WsbTests\\WsbSegment.tst"), 0));
  504. WsbAssertHr(pSegment1->CompareToISegmentRecord(pSegment2, &result));
  505. }WsbCatch(hr);
  506. if (hr == S_OK) {
  507. (*pTestsPassed)++;
  508. } else {
  509. (*pTestsFailed)++;
  510. }
  511. } WsbCatch(hr);
  512. #endif
  513. } WsbCatch(hr);
  514. WsbTraceOut(OLESTR("CSegRec::Test"), OLESTR("hr = <%ls>"),WsbHrAsString(hr));
  515. #else
  516. UNREFERENCED_PARAMETER(pTestsPassed);
  517. UNREFERENCED_PARAMETER(pTestsFailed);
  518. #endif
  519. return(S_OK);
  520. }
  521. HRESULT CSegRec::Print
  522. (
  523. IN IStream* pStream
  524. )
  525. /*++
  526. Implements:
  527. IWsbDbEntity::Print
  528. --*/
  529. {
  530. HRESULT hr = S_OK;
  531. WsbTraceIn(OLESTR("CSegRec::Print"), OLESTR(""));
  532. try {
  533. WsbAssert(0 != pStream, E_POINTER);
  534. CWsbStringPtr strGuid;
  535. WsbAffirmHr(WsbSafeGuidAsString(m_BagId, strGuid));
  536. WsbAffirmHr(WsbPrintfToStream(pStream, OLESTR(" BagId = %ls"),
  537. (WCHAR *)strGuid));
  538. WsbAffirmHr(WsbPrintfToStream(pStream, OLESTR(", StartLoc = %ls"),
  539. WsbLonglongAsString(m_SegStartLoc)));
  540. WsbAffirmHr(WsbPrintfToStream(pStream, OLESTR(", SegLen = %ls"),
  541. WsbLonglongAsString(m_SegLen)));
  542. WsbAffirmHr(WsbPrintfToStream(pStream, OLESTR(", SegFlags = %X"),
  543. m_SegFlags));
  544. WsbAffirmHr(WsbSafeGuidAsString(m_PrimPos, strGuid));
  545. WsbAffirmHr(WsbPrintfToStream(pStream, OLESTR(", PrimPos = %ls"),
  546. (WCHAR *)strGuid));
  547. WsbAffirmHr(WsbPrintfToStream(pStream, OLESTR(", SecPos = %ls "),
  548. WsbLonglongAsString(m_SecPos)));
  549. WsbAffirmHr(CWsbDbEntity::Print(pStream));
  550. } WsbCatch(hr);
  551. WsbTraceOut(OLESTR("CSegRec::Print"), OLESTR("hr = <%ls>"), WsbHrAsString(hr));
  552. return(hr);
  553. }
  554. HRESULT
  555. CSegRec::Split
  556. (
  557. IN GUID BagId,
  558. IN LONGLONG SegStartLoc,
  559. IN LONGLONG SegLen,
  560. IN ISegRec* /*pSegRec1*/,
  561. IN ISegRec* /*pSegRec2*/
  562. )
  563. /*++
  564. Routine Description:
  565. See ISegRec::Split().
  566. Arguments:
  567. See ISegRec::Split().
  568. Return Value:
  569. S_OK - Success.
  570. --*/
  571. {
  572. WsbTraceIn(OLESTR("CSegRec::Split"),
  573. OLESTR("GUID = <%ls>, SegStartLoc = <%I64u>, SegLen = <%I64u>"),
  574. WsbGuidAsString(BagId), SegStartLoc, SegLen);
  575. //Fill in the two segment records splitting the current record around the hole
  576. //Note that there may not always be two segments generated by the split e.g., if
  577. //the hole is at the beginning or end of the segment record or if the hole is the
  578. //entire record.
  579. WsbTraceOut(OLESTR("CSegRec::Split"), OLESTR("hr = <%ls>"),
  580. WsbHrAsString(S_OK));
  581. return(S_OK);
  582. }
  583. HRESULT
  584. CSegRec::UpdateKey(
  585. IWsbDbKey *pKey
  586. )
  587. /*++
  588. Implements:
  589. IWsbDbEntity::UpdateKey
  590. --*/
  591. {
  592. HRESULT hr = S_OK;
  593. try {
  594. WsbAffirmHr(pKey->SetToGuid(m_BagId));
  595. WsbAffirmHr(pKey->AppendLonglong(m_SegStartLoc));
  596. } WsbCatch(hr);
  597. return(hr);
  598. }