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.

1193 lines
25 KiB

  1. /*++
  2. 1998 Seagate Software, Inc. All rights reserved.
  3. Module Name:
  4. fsaprem.cpp
  5. Abstract:
  6. Defines the functions for the premigrated list classes.
  7. Author:
  8. Ron White [ronw] 18-Feb-1997
  9. Revision History:
  10. --*/
  11. #include "stdafx.h"
  12. #include "wsb.h"
  13. #include "fsaprem.h"
  14. #define WSB_TRACE_IS WSB_TRACE_BIT_FSA
  15. static USHORT iCountPrem = 0; // Count of existing objects
  16. HRESULT
  17. CFsaPremigratedDb::FinalConstruct(
  18. void
  19. )
  20. /*++
  21. Implements:
  22. CComObjectRoot::FinalConstruct().
  23. --*/
  24. {
  25. HRESULT hr = S_OK;
  26. try {
  27. WsbAssertHr(CWsbDb::FinalConstruct());
  28. m_version = 1;
  29. } WsbCatch(hr);
  30. return(hr);
  31. }
  32. HRESULT
  33. CFsaPremigratedDb::FinalRelease(
  34. void
  35. )
  36. /*++
  37. Implements:
  38. CComObjectRoot::FinalRelease
  39. --*/
  40. {
  41. HRESULT hr = S_OK;
  42. CWsbDb::FinalRelease();
  43. return(hr);
  44. }
  45. HRESULT
  46. CFsaPremigratedDb::GetClassID(
  47. OUT CLSID* pClsid
  48. )
  49. /*++
  50. Implements:
  51. IPersist::GetClassID().
  52. --*/
  53. {
  54. HRESULT hr = S_OK;
  55. try {
  56. WsbAssert(0 != pClsid, E_POINTER);
  57. *pClsid = CLSID_CFsaPremigratedDb;
  58. } WsbCatch(hr);
  59. return(hr);
  60. }
  61. HRESULT
  62. CFsaPremigratedDb::Init(
  63. IN OLECHAR* path,
  64. IN IWsbDbSys* pDbSys,
  65. OUT BOOL* pCreated
  66. )
  67. /*++
  68. Implements:
  69. IFsaPremigrated::Init
  70. --*/
  71. {
  72. BOOL created = FALSE;
  73. HRESULT hr = S_OK;
  74. WsbTraceIn(OLESTR("CFsaPremigratedDb::Init"),OLESTR(""));
  75. try {
  76. int i = 0;
  77. m_pWsbDbSys = pDbSys;
  78. WsbAffirmPointer(m_pWsbDbSys);
  79. // Attempt to find the DB
  80. hr = Locate(path);
  81. if (S_OK != hr) {
  82. WsbTrace(OLESTR("CFsaPremigratedDb::Init: db Locate failed\n"));
  83. if (STG_E_FILENOTFOUND != hr) {
  84. // Got some error; try deleting the DB and recreating it
  85. WsbTrace(OLESTR("CFsaPremigratedDb::Init: deleting DB\n"));
  86. WsbAffirmHr(Delete(path));
  87. hr = STG_E_FILENOTFOUND;
  88. }
  89. }
  90. if (STG_E_FILENOTFOUND == hr){
  91. ULONG memSize;
  92. hr = S_OK;
  93. m_nRecTypes = 2;
  94. memSize = m_nRecTypes * sizeof(IDB_REC_INFO);
  95. m_RecInfo = (IDB_REC_INFO*)WsbAlloc(memSize);
  96. WsbAffirm(0 != m_RecInfo, E_FAIL);
  97. ZeroMemory(m_RecInfo, memSize);
  98. // Premigrated file record type
  99. m_RecInfo[0].Type = PREMIGRATED_REC_TYPE;
  100. m_RecInfo[0].EntityClassId = CLSID_CFsaPremigratedRec;
  101. m_RecInfo[0].Flags = IDB_REC_FLAG_VARIABLE;
  102. m_RecInfo[0].MinSize = (2 * WsbPersistSizeOf(FILETIME)) +
  103. (5 * WsbPersistSizeOf(LONGLONG)) +
  104. WsbPersistSizeOf(GUID) + 4 + WsbPersistSizeOf(BOOL);
  105. m_RecInfo[0].MaxSize = m_RecInfo[0].MinSize + PREMIGRATED_MAX_PATH_SIZE;
  106. m_RecInfo[0].nKeys = 3;
  107. memSize = m_RecInfo[0].nKeys * sizeof(IDB_KEY_INFO);
  108. m_RecInfo[0].Key = (IDB_KEY_INFO*)WsbAlloc(memSize);
  109. WsbAffirm(0 != m_RecInfo[0].Key, E_FAIL);
  110. ZeroMemory(m_RecInfo[0].Key, memSize);
  111. // This is the default key used after a GetEntity call
  112. m_RecInfo[0].Key[0].Type = PREMIGRATED_ACCESS_TIME_KEY_TYPE;
  113. m_RecInfo[0].Key[0].Size = WSB_BYTE_SIZE_BOOL + WSB_BYTE_SIZE_FILETIME + WSB_BYTE_SIZE_LONGLONG + WSB_BYTE_SIZE_GUID;
  114. m_RecInfo[0].Key[0].Flags = IDB_KEY_FLAG_DUP_ALLOWED;
  115. // This is the primary key, which controls how the records are
  116. // arranged in the DB
  117. m_RecInfo[0].Key[1].Type = PREMIGRATED_BAGID_OFFSETS_KEY_TYPE;
  118. m_RecInfo[0].Key[1].Size = WSB_BYTE_SIZE_BOOL + 2 * WSB_BYTE_SIZE_LONGLONG + WSB_BYTE_SIZE_GUID;
  119. m_RecInfo[0].Key[1].Flags = IDB_KEY_FLAG_PRIMARY;
  120. m_RecInfo[0].Key[2].Type = PREMIGRATED_SIZE_KEY_TYPE;
  121. m_RecInfo[0].Key[2].Size = WSB_BYTE_SIZE_BOOL + WSB_BYTE_SIZE_LONGLONG + WSB_BYTE_SIZE_LONGLONG + WSB_BYTE_SIZE_GUID;
  122. m_RecInfo[0].Key[2].Flags = IDB_KEY_FLAG_DUP_ALLOWED;
  123. WsbAffirm(m_RecInfo[0].nKeys <= IDB_MAX_KEYS_PER_REC, E_FAIL);
  124. // Recovery record type
  125. m_RecInfo[1].Type = RECOVERY_REC_TYPE;
  126. m_RecInfo[1].EntityClassId = CLSID_CFsaRecoveryRec;
  127. m_RecInfo[1].Flags = IDB_REC_FLAG_VARIABLE;
  128. m_RecInfo[1].MinSize = 4 * WsbPersistSizeOf(LONGLONG) +
  129. WsbPersistSizeOf(LONG) + WsbPersistSizeOf(ULONG) + WsbPersistSizeOf(GUID) + 4;
  130. m_RecInfo[1].MaxSize = m_RecInfo[1].MinSize + PREMIGRATED_MAX_PATH_SIZE;
  131. m_RecInfo[1].nKeys = 1;
  132. memSize = m_RecInfo[1].nKeys * sizeof(IDB_KEY_INFO);
  133. m_RecInfo[1].Key = (IDB_KEY_INFO*)WsbAlloc(memSize);
  134. WsbAffirm(0 != m_RecInfo[1].Key, E_FAIL);
  135. ZeroMemory(m_RecInfo[1].Key, memSize);
  136. // This is the default and primary key
  137. m_RecInfo[1].Key[0].Type = RECOVERY_KEY_TYPE;
  138. m_RecInfo[1].Key[0].Size = RECOVERY_KEY_SIZE;
  139. m_RecInfo[1].Key[0].Flags = IDB_KEY_FLAG_PRIMARY;
  140. // Attempt to create the DB
  141. WsbAssertHr(Create(path));
  142. created = TRUE;
  143. } else {
  144. WsbAffirmHr(hr);
  145. }
  146. } WsbCatch(hr);
  147. if (pCreated) {
  148. *pCreated = created;
  149. }
  150. WsbTraceOut(OLESTR("CFsaPremigratedDb::Init"),
  151. OLESTR("hr = <%ls>, Created = %ls"), WsbHrAsString(hr),
  152. WsbBoolAsString(created));
  153. return(hr);
  154. }
  155. HRESULT
  156. CFsaPremigratedDb::Load(
  157. IN IStream* pStream
  158. )
  159. /*++
  160. Implements:
  161. IPersistStream::Load().
  162. --*/
  163. {
  164. HRESULT hr = S_OK;
  165. hr = CWsbDb::Load(pStream);
  166. if (S_OK != hr && STG_E_FILENOTFOUND != hr) {
  167. // Got some error; delete the DB (we'll recreate it later if
  168. // we need it
  169. WsbTrace(OLESTR("CFsaPremigratedDb::Load: deleting DB\n"));
  170. if (S_OK == Delete(NULL)) {
  171. hr = STG_E_FILENOTFOUND;
  172. }
  173. }
  174. return(hr);
  175. }
  176. HRESULT
  177. CFsaPremigratedDb::Save(
  178. IN IStream* pStream,
  179. IN BOOL clearDirty
  180. )
  181. /*++
  182. Implements:
  183. IPersistStream::Save().
  184. --*/
  185. {
  186. HRESULT hr = S_OK;
  187. try {
  188. WsbAffirmHr(CWsbDb::Save(pStream, clearDirty));
  189. } WsbCatch(hr);
  190. return(hr);
  191. }
  192. HRESULT
  193. CFsaPremigratedRec::GetAccessTime(
  194. OUT FILETIME* pAccessTime
  195. )
  196. /*++
  197. Implements:
  198. IFsaPremigratedRec::GetAccessTime
  199. --*/
  200. {
  201. HRESULT hr = S_OK;
  202. WsbTraceIn(OLESTR("CFsaPremigratedRec::GetAccessTime"),OLESTR(""));
  203. try {
  204. WsbAssert(0 != pAccessTime, E_POINTER);
  205. *pAccessTime = m_AccessTime;
  206. } WsbCatch(hr);
  207. WsbTraceOut(OLESTR("CFsaPremigratedRec::GetAccessTime"),
  208. OLESTR("hr = <%ls>"), WsbHrAsString(hr));
  209. return(hr);
  210. }
  211. HRESULT
  212. CFsaPremigratedRec::GetBagId(
  213. OUT GUID* pId
  214. )
  215. /*++
  216. Implements:
  217. IFsaPremigratedRec::GetBagId
  218. --*/
  219. {
  220. HRESULT hr = S_OK;
  221. WsbTraceIn(OLESTR("CFsaPremigratedRec::GetBagId"),OLESTR(""));
  222. try {
  223. WsbAssert(0 != pId, E_POINTER);
  224. *pId = m_BagId;
  225. } WsbCatch(hr);
  226. WsbTraceOut(OLESTR("CFsaPremigratedRec::GetBagId"), OLESTR("hr = <%ls> Id = <%ls>"), WsbHrAsString(hr), WsbGuidAsString(*pId));
  227. return(hr);
  228. }
  229. HRESULT
  230. CFsaPremigratedRec::GetBagOffset(
  231. OUT LONGLONG* pOffset
  232. )
  233. /*++
  234. Implements:
  235. IFsaPremigratedRec::GetBagOffset
  236. --*/
  237. {
  238. HRESULT hr = S_OK;
  239. WsbTraceIn(OLESTR("CFsaPremigratedRec::GetBagOffset"),OLESTR(""));
  240. try {
  241. WsbAssert(0 != pOffset, E_POINTER);
  242. *pOffset = m_BagOffset;
  243. } WsbCatch(hr);
  244. WsbTraceOut(OLESTR("CFsaPremigratedRec::GetBagOffset"), OLESTR("hr = <%ls> Offset = <%ls>"), WsbHrAsString(hr), WsbLonglongAsString(*pOffset));
  245. return(hr);
  246. }
  247. HRESULT
  248. CFsaPremigratedRec::GetFileId(
  249. OUT LONGLONG* pFileId
  250. )
  251. /*++
  252. Implements:
  253. IFsaPremigratedRec::GetFileId
  254. --*/
  255. {
  256. HRESULT hr = S_OK;
  257. WsbTraceIn(OLESTR("CFsaPremigratedRec::GetFileId"),OLESTR(""));
  258. try {
  259. WsbAssert(0 != pFileId, E_POINTER);
  260. *pFileId = m_FileId;
  261. } WsbCatch(hr);
  262. WsbTraceOut(OLESTR("CFsaPremigratedRec::GetFileId"),
  263. OLESTR("hr = <%ls> FileId = <%ls>"), WsbHrAsString( hr ), WsbLonglongAsString( *pFileId ) );
  264. return(hr);
  265. }
  266. HRESULT
  267. CFsaPremigratedRec::GetFileUSN(
  268. OUT LONGLONG* pFileUSN
  269. )
  270. /*++
  271. Implements:
  272. IFsaPremigratedRec::GetFileUSN
  273. --*/
  274. {
  275. HRESULT hr = S_OK;
  276. WsbTraceIn(OLESTR("CFsaPremigratedRec::GetFileUSN"),OLESTR(""));
  277. try {
  278. WsbAssert(0 != pFileUSN, E_POINTER);
  279. *pFileUSN = m_FileUSN;
  280. } WsbCatch(hr);
  281. WsbTraceOut(OLESTR("CFsaPremigratedRec::GetFileUSN"),
  282. OLESTR("hr = <%ls> File USN = <%ls>"), WsbHrAsString( hr ), WsbLonglongAsString( *pFileUSN ) );
  283. return(hr);
  284. }
  285. HRESULT
  286. CFsaPremigratedRec::GetOffset(
  287. OUT LONGLONG* pOffset
  288. )
  289. /*++
  290. Implements:
  291. IFsaPremigratedRec::GetOffset
  292. --*/
  293. {
  294. HRESULT hr = S_OK;
  295. WsbTraceIn(OLESTR("CFsaPremigratedRec::GetOffset"),OLESTR(""));
  296. try {
  297. WsbAssert(0 != pOffset, E_POINTER);
  298. *pOffset = m_Offset;
  299. } WsbCatch(hr);
  300. WsbTraceOut(OLESTR("CFsaPremigratedRec::GetOffset"),
  301. OLESTR("hr = <%ls> Offset = <%ls>"), WsbHrAsString( hr ), WsbLonglongAsString( *pOffset ) );
  302. return(hr);
  303. }
  304. HRESULT
  305. CFsaPremigratedRec::GetPath(
  306. OUT OLECHAR** ppPath,
  307. IN ULONG bufferSize
  308. )
  309. /*++
  310. Implements:
  311. IFsaPremigratedRec::GetPath
  312. --*/
  313. {
  314. HRESULT hr = S_OK;
  315. WsbTraceIn(OLESTR("CFsaPremigratedRec::GetPath"),OLESTR(""));
  316. try {
  317. WsbAssert(0 != ppPath, E_POINTER);
  318. WsbAffirmHr(m_Path.CopyTo(ppPath, bufferSize));
  319. WsbTrace( OLESTR("CFsaPremigratedRec::GetPath path = <%ls>\n"), *ppPath );
  320. } WsbCatch(hr);
  321. WsbTraceOut(OLESTR("CFsaPremigratedRec::GetPath"),
  322. OLESTR("hr = <%ls>"), WsbHrAsString(hr));
  323. return(hr);
  324. }
  325. HRESULT
  326. CFsaPremigratedRec::GetRecallTime(
  327. OUT FILETIME* pTime
  328. )
  329. /*++
  330. Implements:
  331. IFsaPremigratedRec::GetRecallTime
  332. --*/
  333. {
  334. HRESULT hr = S_OK;
  335. WsbTraceIn(OLESTR("CFsaPremigratedRec::GetRecallTime"),OLESTR(""));
  336. try {
  337. WsbAssert(0 != pTime, E_POINTER);
  338. *pTime = m_RecallTime;
  339. } WsbCatch(hr);
  340. WsbTraceOut(OLESTR("CFsaPremigratedRec::GetRecallTime"),
  341. OLESTR("hr = <%ls>"), WsbHrAsString(hr));
  342. return(hr);
  343. }
  344. HRESULT
  345. CFsaPremigratedRec::GetSize(
  346. OUT LONGLONG* pSize
  347. )
  348. /*++
  349. Implements:
  350. IFsaPremigratedRec::GetSize
  351. --*/
  352. {
  353. HRESULT hr = S_OK;
  354. WsbTraceIn(OLESTR("CFsaPremigratedRec::GetSize"),OLESTR(""));
  355. try {
  356. WsbAssert(0 != pSize, E_POINTER);
  357. *pSize = m_Size;
  358. } WsbCatch(hr);
  359. WsbTraceOut(OLESTR("CFsaPremigratedRec::GetSize"),
  360. OLESTR("hr = <%ls> Size = <%ls>"), WsbHrAsString( hr ), WsbLonglongAsString( *pSize ) );
  361. return(hr);
  362. }
  363. HRESULT
  364. CFsaPremigratedRec::FinalConstruct(
  365. void
  366. )
  367. /*++
  368. Implements:
  369. CComObjectRoot::FinalConstruct().
  370. --*/
  371. {
  372. HRESULT hr = S_OK;
  373. try {
  374. WsbAssertHr(CWsbDbEntity::FinalConstruct());
  375. m_AccessTime.dwLowDateTime = 0;
  376. m_AccessTime.dwHighDateTime = 0;
  377. m_BagOffset = 0;
  378. m_BagId = GUID_NULL;
  379. m_FileId = 0;
  380. m_IsWaitingForClose = FALSE;
  381. m_Size = 0;
  382. m_Offset = 0;
  383. m_FileUSN = 0;
  384. } WsbCatch(hr);
  385. iCountPrem++;
  386. return(hr);
  387. }
  388. HRESULT
  389. CFsaPremigratedRec::FinalRelease(
  390. void
  391. )
  392. /*++
  393. Implements:
  394. CComObjectRoot::FinalRelease
  395. --*/
  396. {
  397. HRESULT hr = S_OK;
  398. CWsbDbEntity::FinalRelease();
  399. iCountPrem--;
  400. return(hr);
  401. }
  402. HRESULT CFsaPremigratedRec::GetClassID
  403. (
  404. OUT LPCLSID pclsid
  405. )
  406. /*++
  407. Implements:
  408. IPerist::GetClassID
  409. --*/
  410. {
  411. HRESULT hr = S_OK;
  412. WsbTraceIn(OLESTR("CFsaPremigratedRec::GetClassID"), OLESTR(""));
  413. try {
  414. WsbAssert(0 != pclsid, E_POINTER);
  415. *pclsid = CLSID_CFsaPremigratedRec;
  416. } WsbCatch(hr);
  417. WsbTraceOut(OLESTR("CSecRec::GetClassID"), OLESTR("hr = <%ls>, CLSID = <%ls>"), WsbHrAsString(hr), WsbGuidAsString(*pclsid));
  418. return(hr);
  419. }
  420. HRESULT CFsaPremigratedRec::GetSizeMax
  421. (
  422. OUT ULARGE_INTEGER* pcbSize
  423. )
  424. /*++
  425. Routine Description:
  426. See IPersistStream::GetSizeMax().
  427. Arguments:
  428. See IPersistStream::GetSizeMax().
  429. Return Value:
  430. See IPersistStream::GetSizeMax().
  431. --*/
  432. {
  433. HRESULT hr = S_OK;
  434. WsbTraceIn(OLESTR("CFsaPremigratedRec::GetSizeMax"), OLESTR(""));
  435. try {
  436. WsbAssert(0 != pcbSize, E_POINTER);
  437. pcbSize->QuadPart = WsbPersistSizeOf(FILETIME) +
  438. WsbPersistSizeOf(BOOL) +
  439. WsbPersistSizeOf(GUID) +
  440. 4 * WsbPersistSizeOf(LONGLONG) +
  441. WsbPersistSize((wcslen(m_Path) + 1) * sizeof(OLECHAR));
  442. } WsbCatch(hr);
  443. WsbTraceOut(OLESTR("CFsaPremigratedRec::GetSizeMax"),
  444. OLESTR("hr = <%ls>, Size = <%ls>"), WsbHrAsString(hr),
  445. WsbPtrToUliAsString(pcbSize));
  446. return(hr);
  447. }
  448. HRESULT
  449. CFsaPremigratedRec::IsWaitingForClose(
  450. void
  451. )
  452. /*++
  453. Implements:
  454. IFsaPremigratedRec::IsWaitingForClose
  455. --*/
  456. {
  457. HRESULT hr = S_FALSE;
  458. WsbTraceIn(OLESTR("CFsaPremigratedRec::IsWaitingForClose"),OLESTR(""));
  459. if (m_IsWaitingForClose) {
  460. hr = S_OK;
  461. }
  462. WsbTraceOut(OLESTR("CFsaPremigratedRec::IsWaitingForClose"), OLESTR("hr = <%ls>"), WsbHrAsString(hr));
  463. return(hr);
  464. }
  465. HRESULT CFsaPremigratedRec::Load
  466. (
  467. IN IStream* pStream
  468. )
  469. /*++
  470. Implements:
  471. IPersistStream::Load
  472. --*/
  473. {
  474. HRESULT hr = S_OK;
  475. WsbTraceIn(OLESTR("CFsaPremigratedRec::Load"), OLESTR(""));
  476. try {
  477. WsbAssert(0 != pStream, E_POINTER);
  478. WsbAssertHr(WsbLoadFromStream(pStream, &m_AccessTime));
  479. WsbAssertHr(WsbLoadFromStream(pStream, &m_BagId));
  480. WsbAssertHr(WsbLoadFromStream(pStream, &m_BagOffset));
  481. WsbAssertHr(WsbLoadFromStream(pStream, &m_FileId));
  482. WsbAssertHr(WsbLoadFromStream(pStream, &m_IsWaitingForClose));
  483. WsbAssertHr(WsbLoadFromStream(pStream, &m_Offset));
  484. WsbAssertHr(WsbLoadFromStream(pStream, &m_Path, 0));
  485. WsbAssertHr(WsbLoadFromStream(pStream, &m_Size));
  486. WsbAssertHr(WsbLoadFromStream(pStream, &m_RecallTime));
  487. WsbAssertHr(WsbLoadFromStream(pStream, &m_FileUSN));
  488. } WsbCatch(hr);
  489. WsbTraceOut(OLESTR("CFsaPremigratedRec::Load"),
  490. OLESTR("hr = <%ls>"), WsbHrAsString(hr));
  491. return(hr);
  492. }
  493. HRESULT CFsaPremigratedRec::Print
  494. (
  495. IN IStream* pStream
  496. )
  497. /*++
  498. Implements:
  499. IWsbDbEntity::Print
  500. --*/
  501. {
  502. HRESULT hr = S_OK;
  503. WsbTraceIn(OLESTR("CFsaPremigratedRec::Print"), OLESTR(""));
  504. try {
  505. WsbAssert(0 != pStream, E_POINTER);
  506. CWsbStringPtr strGuid;
  507. WsbAffirmHr(WsbPrintfToStream(pStream, OLESTR(" AccessTime = %ls"),
  508. WsbFiletimeAsString(FALSE, m_AccessTime)));
  509. WsbAffirmHr(WsbSafeGuidAsString(m_BagId, strGuid));
  510. WsbAffirmHr(WsbPrintfToStream(pStream, OLESTR(" BagId = %ls"),
  511. (WCHAR *)strGuid));
  512. WsbAffirmHr(WsbPrintfToStream(pStream, OLESTR(", BagOffset = %ls"),
  513. WsbLonglongAsString(m_BagOffset)));
  514. WsbAffirmHr(WsbPrintfToStream(pStream, OLESTR(", FileId = %ls"),
  515. WsbLonglongAsString(m_FileId)));
  516. WsbAffirmHr(WsbPrintfToStream(pStream, OLESTR(" Waiting for close = %ls"),
  517. WsbBoolAsString(m_IsWaitingForClose)));
  518. WsbAffirmHr(WsbPrintfToStream(pStream, OLESTR(", Offset = %ls"),
  519. WsbLonglongAsString(m_Offset)));
  520. WsbAffirmHr(WsbPrintfToStream(pStream, OLESTR(", Path = %ls"),
  521. static_cast<OLECHAR*>(m_Path)));
  522. WsbAffirmHr(WsbPrintfToStream(pStream, OLESTR(", Size = %ls"),
  523. WsbLonglongAsString(m_Size)));
  524. WsbAffirmHr(WsbPrintfToStream(pStream, OLESTR(" RecallTime = %ls"),
  525. WsbFiletimeAsString(FALSE, m_RecallTime)));
  526. WsbAffirmHr(WsbPrintfToStream(pStream, OLESTR(", File USN = %ls"),
  527. WsbLonglongAsString(m_FileUSN)));
  528. WsbAffirmHr(CWsbDbEntity::Print(pStream));
  529. } WsbCatch(hr);
  530. WsbTraceOut(OLESTR("CFsaPremigratedRec::Print"), OLESTR("hr = <%ls>"), WsbHrAsString(hr));
  531. return(hr);
  532. }
  533. HRESULT CFsaPremigratedRec::Save
  534. (
  535. IN IStream* pStream,
  536. IN BOOL clearDirty
  537. )
  538. /*++
  539. Implements:
  540. IPersistStream::Save
  541. --*/
  542. {
  543. HRESULT hr = S_OK;
  544. WsbTraceIn(OLESTR("CFsaPremigratedRec::Save"), OLESTR("clearDirty = <%ls>"), WsbBoolAsString(clearDirty));
  545. try {
  546. WsbAssert(0 != pStream, E_POINTER);
  547. WsbAssertHr(WsbSaveToStream(pStream, m_AccessTime));
  548. WsbAssertHr(WsbSaveToStream(pStream, m_BagId));
  549. WsbAssertHr(WsbSaveToStream(pStream, m_BagOffset));
  550. WsbAssertHr(WsbSaveToStream(pStream, m_FileId));
  551. WsbAssertHr(WsbSaveToStream(pStream, m_IsWaitingForClose));
  552. WsbAssertHr(WsbSaveToStream(pStream, m_Offset));
  553. WsbAssertHr(WsbSaveToStream(pStream, m_Path));
  554. WsbAssertHr(WsbSaveToStream(pStream, m_Size));
  555. WsbAssertHr(WsbSaveToStream(pStream, m_RecallTime));
  556. WsbAssertHr(WsbSaveToStream(pStream, m_FileUSN));
  557. // If we got it saved and we were asked to clear the dirty bit, then
  558. // do so now.
  559. if (clearDirty) {
  560. m_isDirty = FALSE;
  561. }
  562. } WsbCatch(hr);
  563. WsbTraceOut(OLESTR("CFsaPremigratedRec::Save"), OLESTR("hr = <%ls>"), WsbHrAsString(hr));
  564. return(hr);
  565. }
  566. HRESULT
  567. CFsaPremigratedRec::SetAccessTime(
  568. IN FILETIME AccessTime
  569. )
  570. /*++
  571. Implements:
  572. IFsaPremigratedRec::SetAccessTime
  573. --*/
  574. {
  575. HRESULT hr = S_OK;
  576. WsbTraceIn(OLESTR("CFsaPremigratedRec::SetAccessTime"),OLESTR(""));
  577. try {
  578. m_AccessTime = AccessTime;
  579. } WsbCatch(hr);
  580. WsbTraceOut(OLESTR("CFsaPremigratedRec::SetAccessTime"),
  581. OLESTR("hr = <%ls>"), WsbHrAsString(hr));
  582. return(hr);
  583. }
  584. HRESULT
  585. CFsaPremigratedRec::SetFromScanItem(
  586. IN IFsaScanItem* pScanItem,
  587. IN LONGLONG offset,
  588. IN LONGLONG size,
  589. IN BOOL isWaitingForClose
  590. )
  591. /*++
  592. Implements:
  593. IFsaPremigratedRec::SetFromScanItem
  594. --*/
  595. {
  596. HRESULT hr = S_OK;
  597. FSA_PLACEHOLDER placeholder;
  598. WsbTraceIn(OLESTR("CFsaPremigratedRec::SetFromScanItem"),OLESTR(""));
  599. try {
  600. WsbAssert(0 != pScanItem, E_POINTER);
  601. // Get the name of the file
  602. WsbAffirmHr(pScanItem->GetPathAndName(0, &m_Path, 0));
  603. WsbTrace(OLESTR("CFsaPremigratedRec::SetFromScanItem: path = %ls\n"),
  604. static_cast<WCHAR*>(m_Path));
  605. // Get the file id.
  606. WsbAffirmHr(pScanItem->GetFileId(&m_FileId));
  607. // Get the access time, offset, and size.
  608. WsbAffirmHr(pScanItem->GetAccessTime(&m_AccessTime));
  609. WsbTrace(OLESTR("CFsaPremigratedRec::SetFromScanItem: access time = %ls\n"),
  610. WsbFiletimeAsString(FALSE, m_AccessTime));
  611. m_Offset = offset;
  612. m_Size = size;
  613. m_IsWaitingForClose = isWaitingForClose;
  614. // Get the bag id and offset.
  615. WsbAffirmHr(pScanItem->GetPlaceholder(offset, size, &placeholder));
  616. m_BagId = placeholder.bagId;
  617. m_BagOffset = placeholder.fileStart;
  618. m_RecallTime = placeholder.recallTime;
  619. WsbTrace(OLESTR("CFsaPremigratedRec::SetFromScanItem: recall time = %ls\n"),
  620. WsbFiletimeAsString(FALSE, m_RecallTime));
  621. } WsbCatch(hr);
  622. WsbTraceOut(OLESTR("CFsaPremigratedRec::SetFromScanItem"),
  623. OLESTR("hr = <%ls>"), WsbHrAsString(hr));
  624. return(hr);
  625. }
  626. HRESULT
  627. CFsaPremigratedRec::SetBagId(
  628. IN GUID BagId
  629. )
  630. /*++
  631. Implements:
  632. IFsaPremigratedRec::SetBagId
  633. --*/
  634. {
  635. HRESULT hr = S_OK;
  636. WsbTraceIn(OLESTR("CFsaPremigratedRec::SetBagId"),OLESTR(""));
  637. m_BagId = BagId;
  638. WsbTraceOut(OLESTR("CFsaPremigratedRec::SetBagId"), OLESTR("hr = <%ls>"), WsbHrAsString(hr));
  639. return(hr);
  640. }
  641. HRESULT
  642. CFsaPremigratedRec::SetBagOffset(
  643. IN LONGLONG BagOffset
  644. )
  645. /*++
  646. Implements:
  647. IFsaPremigratedRec::SetBagOffset
  648. --*/
  649. {
  650. HRESULT hr = S_OK;
  651. WsbTraceIn(OLESTR("CFsaPremigratedRec::SetBagOffset"),OLESTR(""));
  652. m_BagOffset = BagOffset;
  653. WsbTraceOut(OLESTR("CFsaPremigratedRec::SetBagOffset"), OLESTR("hr = <%ls>"), WsbHrAsString(hr));
  654. return(hr);
  655. }
  656. HRESULT
  657. CFsaPremigratedRec::SetFileId(
  658. IN LONGLONG FileId
  659. )
  660. /*++
  661. Implements:
  662. IFsaPremigratedRec::SetFileId
  663. --*/
  664. {
  665. HRESULT hr = S_OK;
  666. WsbTraceIn(OLESTR("CFsaPremigratedRec::SetFileId"),OLESTR("FileId = %ls"),
  667. WsbLonglongAsString(FileId));
  668. try {
  669. m_FileId = FileId;
  670. } WsbCatch(hr);
  671. WsbTraceOut(OLESTR("CFsaPremigratedRec::SetFileId"), OLESTR("hr = <%ls>"), WsbHrAsString(hr));
  672. return(hr);
  673. }
  674. HRESULT
  675. CFsaPremigratedRec::SetFileUSN(
  676. IN LONGLONG FileUSN
  677. )
  678. /*++
  679. Implements:
  680. IFsaPremigratedRec::SetFileUSN
  681. --*/
  682. {
  683. HRESULT hr = S_OK;
  684. WsbTraceIn(OLESTR("CFsaPremigratedRec::SetFileUSN"),OLESTR("File USN = %ls"),
  685. WsbLonglongAsString(FileUSN));
  686. try {
  687. m_FileUSN = FileUSN;
  688. } WsbCatch(hr);
  689. WsbTraceOut(OLESTR("CFsaPremigratedRec::SetFileUSN"), OLESTR("hr = <%ls>"), WsbHrAsString(hr));
  690. return(hr);
  691. }
  692. HRESULT
  693. CFsaPremigratedRec::SetIsWaitingForClose(
  694. IN BOOL isWaiting
  695. )
  696. /*++
  697. Implements:
  698. IFsaPremigratedRec::SetIsWaitingForClose
  699. --*/
  700. {
  701. HRESULT hr = S_OK;
  702. WsbTraceIn(OLESTR("CFsaPremigratedRec::SetIsWaitingForClose"),OLESTR(""));
  703. m_IsWaitingForClose = isWaiting;
  704. WsbTraceOut(OLESTR("CFsaPremigratedRec::SetIsWaitingForClose"), OLESTR("hr = <%ls>"), WsbHrAsString(hr));
  705. return(hr);
  706. }
  707. HRESULT
  708. CFsaPremigratedRec::SetOffset(
  709. IN LONGLONG Offset
  710. )
  711. /*++
  712. Implements:
  713. IFsaPremigratedRec::SetOffset
  714. --*/
  715. {
  716. HRESULT hr = S_OK;
  717. WsbTraceIn(OLESTR("CFsaPremigratedRec::SetOffset"),OLESTR(""));
  718. try {
  719. m_Offset = Offset;
  720. } WsbCatch(hr);
  721. WsbTraceOut(OLESTR("CFsaPremigratedRec::SetOffset"),
  722. OLESTR("hr = <%ls>"), WsbHrAsString(hr));
  723. return(hr);
  724. }
  725. HRESULT
  726. CFsaPremigratedRec::SetPath(
  727. IN OLECHAR* Path
  728. )
  729. /*++
  730. Implements:
  731. IFsaPremigratedRec::SetPath
  732. --*/
  733. {
  734. HRESULT hr = S_OK;
  735. WsbTraceIn(OLESTR("CFsaPremigratedRec::SetPath"),OLESTR(""));
  736. try {
  737. m_Path = Path;
  738. } WsbCatch(hr);
  739. WsbTraceOut(OLESTR("CFsaPremigratedRec::SetPath"), OLESTR("hr = <%ls>"), WsbHrAsString(hr));
  740. return(hr);
  741. }
  742. HRESULT
  743. CFsaPremigratedRec::SetRecallTime(
  744. IN FILETIME time
  745. )
  746. /*++
  747. Implements:
  748. IFsaPremigratedRec::SetRecallTime
  749. --*/
  750. {
  751. HRESULT hr = S_OK;
  752. WsbTraceIn(OLESTR("CFsaPremigratedRec::SetRecallTime"),OLESTR(""));
  753. try {
  754. m_RecallTime = time;
  755. } WsbCatch(hr);
  756. WsbTraceOut(OLESTR("CFsaPremigratedRec::SetRecallTime"),
  757. OLESTR("hr = <%ls>"), WsbHrAsString(hr));
  758. return(hr);
  759. }
  760. HRESULT
  761. CFsaPremigratedRec::SetSize(
  762. IN LONGLONG Size
  763. )
  764. /*++
  765. Implements:
  766. IFsaPremigratedRec::SetSize
  767. --*/
  768. {
  769. HRESULT hr = S_OK;
  770. WsbTraceIn(OLESTR("CFsaPremigratedRec::SetSize"),OLESTR(""));
  771. try {
  772. m_Size = Size;
  773. } WsbCatch(hr);
  774. WsbTraceOut(OLESTR("CFsaPremigratedRec::SetSize"), OLESTR("hr = <%ls>"), WsbHrAsString(hr));
  775. return(hr);
  776. }
  777. HRESULT
  778. CFsaPremigratedRec::UpdateKey(
  779. IWsbDbKey *pKey
  780. )
  781. /*++
  782. Implements:
  783. IWsbDbEntity::UpdateKey
  784. --*/
  785. {
  786. HRESULT hr = S_OK;
  787. try {
  788. ULONG KeyType;
  789. WsbAffirmHr(pKey->GetType(&KeyType));
  790. switch (KeyType) {
  791. case PREMIGRATED_ACCESS_TIME_KEY_TYPE:
  792. WsbAffirmHr(pKey->SetToBool(m_IsWaitingForClose));
  793. WsbAffirmHr(pKey->AppendFiletime(m_AccessTime));
  794. WsbAffirmHr(pKey->AppendGuid(m_BagId));
  795. WsbAffirmHr(pKey->AppendLonglong(m_BagOffset));
  796. break;
  797. case PREMIGRATED_BAGID_OFFSETS_KEY_TYPE:
  798. WsbAffirmHr(pKey->SetToGuid(m_BagId));
  799. WsbAffirmHr(pKey->AppendLonglong(m_BagOffset));
  800. WsbAffirmHr(pKey->AppendLonglong(m_Offset));
  801. break;
  802. case PREMIGRATED_SIZE_KEY_TYPE:
  803. WsbAffirmHr(pKey->SetToBool(m_IsWaitingForClose));
  804. WsbAffirmHr(pKey->AppendLonglong(m_Size));
  805. WsbAffirmHr(pKey->AppendGuid(m_BagId));
  806. WsbAffirmHr(pKey->AppendLonglong(m_BagOffset));
  807. break;
  808. }
  809. } WsbCatch(hr);
  810. return(hr);
  811. }