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.

1191 lines
24 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. WsbAffirmHr(WsbPrintfToStream(pStream, OLESTR(" AccessTime = %ls"),
  507. WsbFiletimeAsString(FALSE, m_AccessTime)));
  508. WsbAffirmHr(WsbPrintfToStream(pStream, OLESTR(" BagId = %ls"),
  509. WsbGuidAsString(m_BagId)));
  510. WsbAffirmHr(WsbPrintfToStream(pStream, OLESTR(", BagOffset = %ls"),
  511. WsbLonglongAsString(m_BagOffset)));
  512. WsbAffirmHr(WsbPrintfToStream(pStream, OLESTR(", FileId = %ls"),
  513. WsbLonglongAsString(m_FileId)));
  514. WsbAffirmHr(WsbPrintfToStream(pStream, OLESTR(" Waiting for close = %ls"),
  515. WsbBoolAsString(m_IsWaitingForClose)));
  516. WsbAffirmHr(WsbPrintfToStream(pStream, OLESTR(", Offset = %ls"),
  517. WsbLonglongAsString(m_Offset)));
  518. WsbAffirmHr(WsbPrintfToStream(pStream, OLESTR(", Path = %ls"),
  519. static_cast<OLECHAR*>(m_Path)));
  520. WsbAffirmHr(WsbPrintfToStream(pStream, OLESTR(", Size = %ls"),
  521. WsbLonglongAsString(m_Size)));
  522. WsbAffirmHr(WsbPrintfToStream(pStream, OLESTR(" RecallTime = %ls"),
  523. WsbFiletimeAsString(FALSE, m_RecallTime)));
  524. WsbAffirmHr(WsbPrintfToStream(pStream, OLESTR(", File USN = %ls"),
  525. WsbLonglongAsString(m_FileUSN)));
  526. WsbAffirmHr(CWsbDbEntity::Print(pStream));
  527. } WsbCatch(hr);
  528. WsbTraceOut(OLESTR("CFsaPremigratedRec::Print"), OLESTR("hr = <%ls>"), WsbHrAsString(hr));
  529. return(hr);
  530. }
  531. HRESULT CFsaPremigratedRec::Save
  532. (
  533. IN IStream* pStream,
  534. IN BOOL clearDirty
  535. )
  536. /*++
  537. Implements:
  538. IPersistStream::Save
  539. --*/
  540. {
  541. HRESULT hr = S_OK;
  542. WsbTraceIn(OLESTR("CFsaPremigratedRec::Save"), OLESTR("clearDirty = <%ls>"), WsbBoolAsString(clearDirty));
  543. try {
  544. WsbAssert(0 != pStream, E_POINTER);
  545. WsbAssertHr(WsbSaveToStream(pStream, m_AccessTime));
  546. WsbAssertHr(WsbSaveToStream(pStream, m_BagId));
  547. WsbAssertHr(WsbSaveToStream(pStream, m_BagOffset));
  548. WsbAssertHr(WsbSaveToStream(pStream, m_FileId));
  549. WsbAssertHr(WsbSaveToStream(pStream, m_IsWaitingForClose));
  550. WsbAssertHr(WsbSaveToStream(pStream, m_Offset));
  551. WsbAssertHr(WsbSaveToStream(pStream, m_Path));
  552. WsbAssertHr(WsbSaveToStream(pStream, m_Size));
  553. WsbAssertHr(WsbSaveToStream(pStream, m_RecallTime));
  554. WsbAssertHr(WsbSaveToStream(pStream, m_FileUSN));
  555. // If we got it saved and we were asked to clear the dirty bit, then
  556. // do so now.
  557. if (clearDirty) {
  558. m_isDirty = FALSE;
  559. }
  560. } WsbCatch(hr);
  561. WsbTraceOut(OLESTR("CFsaPremigratedRec::Save"), OLESTR("hr = <%ls>"), WsbHrAsString(hr));
  562. return(hr);
  563. }
  564. HRESULT
  565. CFsaPremigratedRec::SetAccessTime(
  566. IN FILETIME AccessTime
  567. )
  568. /*++
  569. Implements:
  570. IFsaPremigratedRec::SetAccessTime
  571. --*/
  572. {
  573. HRESULT hr = S_OK;
  574. WsbTraceIn(OLESTR("CFsaPremigratedRec::SetAccessTime"),OLESTR(""));
  575. try {
  576. m_AccessTime = AccessTime;
  577. } WsbCatch(hr);
  578. WsbTraceOut(OLESTR("CFsaPremigratedRec::SetAccessTime"),
  579. OLESTR("hr = <%ls>"), WsbHrAsString(hr));
  580. return(hr);
  581. }
  582. HRESULT
  583. CFsaPremigratedRec::SetFromScanItem(
  584. IN IFsaScanItem* pScanItem,
  585. IN LONGLONG offset,
  586. IN LONGLONG size,
  587. IN BOOL isWaitingForClose
  588. )
  589. /*++
  590. Implements:
  591. IFsaPremigratedRec::SetFromScanItem
  592. --*/
  593. {
  594. HRESULT hr = S_OK;
  595. FSA_PLACEHOLDER placeholder;
  596. WsbTraceIn(OLESTR("CFsaPremigratedRec::SetFromScanItem"),OLESTR(""));
  597. try {
  598. WsbAssert(0 != pScanItem, E_POINTER);
  599. // Get the name of the file
  600. WsbAffirmHr(pScanItem->GetPathAndName(0, &m_Path, 0));
  601. WsbTrace(OLESTR("CFsaPremigratedRec::SetFromScanItem: path = %ls\n"),
  602. static_cast<WCHAR*>(m_Path));
  603. // Get the file id.
  604. WsbAffirmHr(pScanItem->GetFileId(&m_FileId));
  605. // Get the access time, offset, and size.
  606. WsbAffirmHr(pScanItem->GetAccessTime(&m_AccessTime));
  607. WsbTrace(OLESTR("CFsaPremigratedRec::SetFromScanItem: access time = %ls\n"),
  608. WsbFiletimeAsString(FALSE, m_AccessTime));
  609. m_Offset = offset;
  610. m_Size = size;
  611. m_IsWaitingForClose = isWaitingForClose;
  612. // Get the bag id and offset.
  613. WsbAffirmHr(pScanItem->GetPlaceholder(offset, size, &placeholder));
  614. m_BagId = placeholder.bagId;
  615. m_BagOffset = placeholder.fileStart;
  616. m_RecallTime = placeholder.recallTime;
  617. WsbTrace(OLESTR("CFsaPremigratedRec::SetFromScanItem: recall time = %ls\n"),
  618. WsbFiletimeAsString(FALSE, m_RecallTime));
  619. } WsbCatch(hr);
  620. WsbTraceOut(OLESTR("CFsaPremigratedRec::SetFromScanItem"),
  621. OLESTR("hr = <%ls>"), WsbHrAsString(hr));
  622. return(hr);
  623. }
  624. HRESULT
  625. CFsaPremigratedRec::SetBagId(
  626. IN GUID BagId
  627. )
  628. /*++
  629. Implements:
  630. IFsaPremigratedRec::SetBagId
  631. --*/
  632. {
  633. HRESULT hr = S_OK;
  634. WsbTraceIn(OLESTR("CFsaPremigratedRec::SetBagId"),OLESTR(""));
  635. m_BagId = BagId;
  636. WsbTraceOut(OLESTR("CFsaPremigratedRec::SetBagId"), OLESTR("hr = <%ls>"), WsbHrAsString(hr));
  637. return(hr);
  638. }
  639. HRESULT
  640. CFsaPremigratedRec::SetBagOffset(
  641. IN LONGLONG BagOffset
  642. )
  643. /*++
  644. Implements:
  645. IFsaPremigratedRec::SetBagOffset
  646. --*/
  647. {
  648. HRESULT hr = S_OK;
  649. WsbTraceIn(OLESTR("CFsaPremigratedRec::SetBagOffset"),OLESTR(""));
  650. m_BagOffset = BagOffset;
  651. WsbTraceOut(OLESTR("CFsaPremigratedRec::SetBagOffset"), OLESTR("hr = <%ls>"), WsbHrAsString(hr));
  652. return(hr);
  653. }
  654. HRESULT
  655. CFsaPremigratedRec::SetFileId(
  656. IN LONGLONG FileId
  657. )
  658. /*++
  659. Implements:
  660. IFsaPremigratedRec::SetFileId
  661. --*/
  662. {
  663. HRESULT hr = S_OK;
  664. WsbTraceIn(OLESTR("CFsaPremigratedRec::SetFileId"),OLESTR("FileId = %ls"),
  665. WsbLonglongAsString(FileId));
  666. try {
  667. m_FileId = FileId;
  668. } WsbCatch(hr);
  669. WsbTraceOut(OLESTR("CFsaPremigratedRec::SetFileId"), OLESTR("hr = <%ls>"), WsbHrAsString(hr));
  670. return(hr);
  671. }
  672. HRESULT
  673. CFsaPremigratedRec::SetFileUSN(
  674. IN LONGLONG FileUSN
  675. )
  676. /*++
  677. Implements:
  678. IFsaPremigratedRec::SetFileUSN
  679. --*/
  680. {
  681. HRESULT hr = S_OK;
  682. WsbTraceIn(OLESTR("CFsaPremigratedRec::SetFileUSN"),OLESTR("File USN = %ls"),
  683. WsbLonglongAsString(FileUSN));
  684. try {
  685. m_FileUSN = FileUSN;
  686. } WsbCatch(hr);
  687. WsbTraceOut(OLESTR("CFsaPremigratedRec::SetFileUSN"), OLESTR("hr = <%ls>"), WsbHrAsString(hr));
  688. return(hr);
  689. }
  690. HRESULT
  691. CFsaPremigratedRec::SetIsWaitingForClose(
  692. IN BOOL isWaiting
  693. )
  694. /*++
  695. Implements:
  696. IFsaPremigratedRec::SetIsWaitingForClose
  697. --*/
  698. {
  699. HRESULT hr = S_OK;
  700. WsbTraceIn(OLESTR("CFsaPremigratedRec::SetIsWaitingForClose"),OLESTR(""));
  701. m_IsWaitingForClose = isWaiting;
  702. WsbTraceOut(OLESTR("CFsaPremigratedRec::SetIsWaitingForClose"), OLESTR("hr = <%ls>"), WsbHrAsString(hr));
  703. return(hr);
  704. }
  705. HRESULT
  706. CFsaPremigratedRec::SetOffset(
  707. IN LONGLONG Offset
  708. )
  709. /*++
  710. Implements:
  711. IFsaPremigratedRec::SetOffset
  712. --*/
  713. {
  714. HRESULT hr = S_OK;
  715. WsbTraceIn(OLESTR("CFsaPremigratedRec::SetOffset"),OLESTR(""));
  716. try {
  717. m_Offset = Offset;
  718. } WsbCatch(hr);
  719. WsbTraceOut(OLESTR("CFsaPremigratedRec::SetOffset"),
  720. OLESTR("hr = <%ls>"), WsbHrAsString(hr));
  721. return(hr);
  722. }
  723. HRESULT
  724. CFsaPremigratedRec::SetPath(
  725. IN OLECHAR* Path
  726. )
  727. /*++
  728. Implements:
  729. IFsaPremigratedRec::SetPath
  730. --*/
  731. {
  732. HRESULT hr = S_OK;
  733. WsbTraceIn(OLESTR("CFsaPremigratedRec::SetPath"),OLESTR(""));
  734. try {
  735. m_Path = Path;
  736. } WsbCatch(hr);
  737. WsbTraceOut(OLESTR("CFsaPremigratedRec::SetPath"), OLESTR("hr = <%ls>"), WsbHrAsString(hr));
  738. return(hr);
  739. }
  740. HRESULT
  741. CFsaPremigratedRec::SetRecallTime(
  742. IN FILETIME time
  743. )
  744. /*++
  745. Implements:
  746. IFsaPremigratedRec::SetRecallTime
  747. --*/
  748. {
  749. HRESULT hr = S_OK;
  750. WsbTraceIn(OLESTR("CFsaPremigratedRec::SetRecallTime"),OLESTR(""));
  751. try {
  752. m_RecallTime = time;
  753. } WsbCatch(hr);
  754. WsbTraceOut(OLESTR("CFsaPremigratedRec::SetRecallTime"),
  755. OLESTR("hr = <%ls>"), WsbHrAsString(hr));
  756. return(hr);
  757. }
  758. HRESULT
  759. CFsaPremigratedRec::SetSize(
  760. IN LONGLONG Size
  761. )
  762. /*++
  763. Implements:
  764. IFsaPremigratedRec::SetSize
  765. --*/
  766. {
  767. HRESULT hr = S_OK;
  768. WsbTraceIn(OLESTR("CFsaPremigratedRec::SetSize"),OLESTR(""));
  769. try {
  770. m_Size = Size;
  771. } WsbCatch(hr);
  772. WsbTraceOut(OLESTR("CFsaPremigratedRec::SetSize"), OLESTR("hr = <%ls>"), WsbHrAsString(hr));
  773. return(hr);
  774. }
  775. HRESULT
  776. CFsaPremigratedRec::UpdateKey(
  777. IWsbDbKey *pKey
  778. )
  779. /*++
  780. Implements:
  781. IWsbDbEntity::UpdateKey
  782. --*/
  783. {
  784. HRESULT hr = S_OK;
  785. try {
  786. ULONG KeyType;
  787. WsbAffirmHr(pKey->GetType(&KeyType));
  788. switch (KeyType) {
  789. case PREMIGRATED_ACCESS_TIME_KEY_TYPE:
  790. WsbAffirmHr(pKey->SetToBool(m_IsWaitingForClose));
  791. WsbAffirmHr(pKey->AppendFiletime(m_AccessTime));
  792. WsbAffirmHr(pKey->AppendGuid(m_BagId));
  793. WsbAffirmHr(pKey->AppendLonglong(m_BagOffset));
  794. break;
  795. case PREMIGRATED_BAGID_OFFSETS_KEY_TYPE:
  796. WsbAffirmHr(pKey->SetToGuid(m_BagId));
  797. WsbAffirmHr(pKey->AppendLonglong(m_BagOffset));
  798. WsbAffirmHr(pKey->AppendLonglong(m_Offset));
  799. break;
  800. case PREMIGRATED_SIZE_KEY_TYPE:
  801. WsbAffirmHr(pKey->SetToBool(m_IsWaitingForClose));
  802. WsbAffirmHr(pKey->AppendLonglong(m_Size));
  803. WsbAffirmHr(pKey->AppendGuid(m_BagId));
  804. WsbAffirmHr(pKey->AppendLonglong(m_BagOffset));
  805. break;
  806. }
  807. } WsbCatch(hr);
  808. return(hr);
  809. }