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.

631 lines
17 KiB

  1. //+--------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1992.
  5. //
  6. // File: entry.cxx
  7. //
  8. // Contents: Entry implementations
  9. //
  10. // History: 29-Jul-92 DrewB Created
  11. // 10-Apr-95 HenryLee remove Sleep
  12. //
  13. //---------------------------------------------------------------
  14. #include <dfhead.cxx>
  15. #include <smalloc.hxx>
  16. #pragma hdrstop
  17. #define PDOCFILE_VCALL(x) \
  18. if (_sig == CDOCFILE_SIG) \
  19. return ((CDocFile *)this)->x; \
  20. else if (_sig == CWRAPPEDDOCFILE_SIG) \
  21. return ((CWrappedDocFile *)this)->x; \
  22. else olAssert (!"Invalid signature on PDocFile!");\
  23. return STG_E_INVALIDFUNCTION;
  24. #define PSSTREAM_VCALL(x) \
  25. if (_sig == CDIRECTSTREAM_SIG) \
  26. return ((CDirectStream *)this)->x; \
  27. else if (_sig == CTRANSACTEDSTREAM_SIG) \
  28. return ((CTransactedStream *)this)->x; \
  29. else olAssert (!"Invalid signature on PSStream!");\
  30. return STG_E_INVALIDFUNCTION;
  31. #define PTIMEENTRY_VCALL(x) \
  32. if (_sig == CDOCFILE_SIG) \
  33. return ((CDocFile *)this)->x; \
  34. else if (_sig == CWRAPPEDDOCFILE_SIG) \
  35. return ((CWrappedDocFile *)this)->x; \
  36. else olAssert (!"Invalid signature on PTimeEntry");\
  37. return STG_E_INVALIDFUNCTION;
  38. //+--------------------------------------------------------------
  39. //
  40. // Member: PTimeEntry::CopyTimesFrom, public
  41. //
  42. // Synopsis: Copies one entries times to another
  43. //
  44. // Arguments: [ptenFrom] - From
  45. //
  46. // Returns: Appropriate status code
  47. //
  48. // History: 29-Jul-92 DrewB Created
  49. // 26-May-95 SusiA Removed GetTime; Added GetAllTimes
  50. // 22-Nov-95 SusiA SetAllTimes at once
  51. //
  52. //---------------------------------------------------------------
  53. SCODE PTimeEntry::CopyTimesFrom(PTimeEntry *ptenFrom)
  54. {
  55. SCODE sc;
  56. TIME_T atm; //Access time
  57. TIME_T mtm; //Modification time
  58. TIME_T ctm; //Creation time
  59. olDebugOut((DEB_ITRACE, "In PTimeEntry::CopyTimesFrom(%p)\n",
  60. ptenFrom));
  61. olChk(ptenFrom->GetAllTimes(&atm, &mtm, &ctm));
  62. olChk(SetAllTimes(atm, mtm, ctm));
  63. olDebugOut((DEB_ITRACE, "Out PTimeEntry::CopyTimesFrom\n"));
  64. // Fall through
  65. EH_Err:
  66. return sc;
  67. }
  68. //+--------------------------------------------------------------
  69. //
  70. // Member: PBasicEntry::GetNewLuid, public
  71. //
  72. // Synopsis: Returns a new luid
  73. //
  74. // History: 21-Oct-92 AlexT Created
  75. //
  76. //---------------------------------------------------------------
  77. //We used to have a mutex here - it turns out that this is unnecessary,
  78. // since we're already holding the tree mutex. We get a performance
  79. // win by eliminating the mutex.
  80. //Using CSmAllocator mutex and took out Sleep()
  81. //static CStaticDfMutex _sdmtxLuids(TSTR("DfLuidsProtector"));
  82. DFLUID PBasicEntry::GetNewLuid(const IMalloc *pMalloc)
  83. {
  84. DFLUID luid;
  85. luid = ((CSmAllocator *)pMalloc)->IncrementLuid();
  86. return luid;
  87. }
  88. //+--------------------------------------------------------------
  89. //
  90. // Member: PTimeEntry::GetTime, public
  91. //
  92. // Synopsis: calls to derived object
  93. //
  94. // History: 20-Jan-98 HenryLee Created
  95. //
  96. //---------------------------------------------------------------
  97. SCODE PTimeEntry::GetTime(WHICHTIME wt, TIME_T *ptm)
  98. {
  99. PTIMEENTRY_VCALL (GetTime (wt, ptm));
  100. }
  101. //+--------------------------------------------------------------
  102. //
  103. // Member: PTimeEntry::SetTime, public
  104. //
  105. // Synopsis: calls to derived object
  106. //
  107. // History: 20-Jan-98 HenryLee Created
  108. //
  109. //---------------------------------------------------------------
  110. SCODE PTimeEntry::SetTime(WHICHTIME wt, TIME_T tm)
  111. {
  112. PTIMEENTRY_VCALL (SetTime (wt, tm));
  113. }
  114. //+--------------------------------------------------------------
  115. //
  116. // Member: PTimeEntry::GetAllTimes, public
  117. //
  118. // Synopsis: calls to derived object
  119. //
  120. // History: 20-Jan-98 HenryLee Created
  121. //
  122. //---------------------------------------------------------------
  123. SCODE PTimeEntry::GetAllTimes(TIME_T *patm, TIME_T *pmtm, TIME_T *pctm)
  124. {
  125. PTIMEENTRY_VCALL (GetAllTimes (patm, pmtm, pctm));
  126. }
  127. //+--------------------------------------------------------------
  128. //
  129. // Member: PTimeEntry::SetTime, public
  130. //
  131. // Synopsis: calls to derived object
  132. //
  133. // History: 20-Jan-98 HenryLee Created
  134. //
  135. //---------------------------------------------------------------
  136. SCODE PTimeEntry::SetAllTimes(TIME_T atm, TIME_T mtm, TIME_T ctm)
  137. {
  138. PTIMEENTRY_VCALL (SetAllTimes (atm, mtm, ctm));
  139. }
  140. //+--------------------------------------------------------------
  141. //
  142. // Member: PBasicEntry::Release, public
  143. //
  144. // Synopsis: Release resources for a PBasicEntry
  145. //
  146. // History: 11-Dec-91 DrewB Created
  147. //
  148. //---------------------------------------------------------------
  149. void PBasicEntry::Release(void)
  150. {
  151. LONG lRet;
  152. olDebugOut((DEB_ITRACE, "In PBasicEntry::Release()\n"));
  153. olAssert(_cReferences > 0);
  154. lRet = AtomicDec(&_cReferences);
  155. if (lRet == 0)
  156. {
  157. if (_sig == CDOCFILE_SIG)
  158. delete (CDocFile *)this;
  159. else if (_sig == CWRAPPEDDOCFILE_SIG)
  160. delete (CWrappedDocFile *)this;
  161. else if (_sig == CDIRECTSTREAM_SIG)
  162. delete (CDirectStream *)this;
  163. else if (_sig == CTRANSACTEDSTREAM_SIG)
  164. delete (CTransactedStream *)this;
  165. else
  166. olAssert (!"Invalid signature on PBasicEntry!");
  167. }
  168. olDebugOut((DEB_ITRACE, "Out PBasicEntry::Release\n"));
  169. }
  170. //+--------------------------------------------------------------
  171. //
  172. // Member: PSStream::BeginCommitFromChild, public
  173. //
  174. // Synopsis: calls to derived object
  175. //
  176. // History: 20-Jan-98 HenryLee Created
  177. //
  178. //---------------------------------------------------------------
  179. SCODE PSStream::BeginCommitFromChild(
  180. #ifdef LARGE_STREAMS
  181. ULONGLONG ulSize,
  182. #else
  183. ULONG ulSize,
  184. #endif
  185. CDeltaList *pDelta,
  186. CTransactedStream *pstChild)
  187. {
  188. PSSTREAM_VCALL (BeginCommitFromChild (ulSize, pDelta, pstChild));
  189. }
  190. //+--------------------------------------------------------------
  191. //
  192. // Member: PSStream::EndCommitFromChild, public
  193. //
  194. // Synopsis: calls to derived object
  195. //
  196. // History: 20-Jan-98 HenryLee Created
  197. //
  198. //---------------------------------------------------------------
  199. void PSStream::EndCommitFromChild(DFLAGS df, CTransactedStream *pstChild)
  200. {
  201. if (_sig == CDIRECTSTREAM_SIG)
  202. ((CDirectStream *)this)->EndCommitFromChild (df, pstChild);
  203. else if (_sig == CTRANSACTEDSTREAM_SIG)
  204. ((CTransactedStream *)this)->EndCommitFromChild (df, pstChild);
  205. else olAssert (!"Invalid signature on PSStream!");
  206. return;
  207. }
  208. //+--------------------------------------------------------------
  209. //
  210. // Member: PSStream::EmptyCache, public
  211. //
  212. // Synopsis: calls to derived object
  213. //
  214. // History: 20-Jan-98 HenryLee Created
  215. //
  216. //---------------------------------------------------------------
  217. void PSStream::EmptyCache()
  218. {
  219. if (_sig == CDIRECTSTREAM_SIG)
  220. ((CDirectStream *)this)->EmptyCache();
  221. else if (_sig == CTRANSACTEDSTREAM_SIG)
  222. ((CTransactedStream *)this)->EmptyCache();
  223. else olAssert (!"Invalid signature on PSStream!");
  224. return;
  225. }
  226. //+--------------------------------------------------------------
  227. //
  228. // Member: PSStream::GetDeltaList, public
  229. //
  230. // Synopsis: calls to derived object
  231. //
  232. // History: 20-Jan-98 HenryLee Created
  233. //
  234. //---------------------------------------------------------------
  235. CDeltaList * PSStream::GetDeltaList(void)
  236. {
  237. if (_sig == CDIRECTSTREAM_SIG)
  238. return ((CDirectStream *)this)->GetDeltaList ();
  239. else if (_sig == CTRANSACTEDSTREAM_SIG)
  240. return ((CTransactedStream *)this)->GetDeltaList ();
  241. else olAssert (!"Invalid signature on PSStream!");
  242. return NULL;
  243. }
  244. //+--------------------------------------------------------------
  245. //
  246. // Member: PSStream::ReadAt, public
  247. //
  248. // Synopsis: calls to derived object
  249. //
  250. // History: 20-Jan-98 HenryLee Created
  251. //
  252. //---------------------------------------------------------------
  253. SCODE PSStream::ReadAt(
  254. #ifdef LARGE_STREAMS
  255. ULONGLONG ulOffset,
  256. #else
  257. ULONG ulOffset,
  258. #endif
  259. VOID *pBuffer,
  260. ULONG ulCount,
  261. ULONG STACKBASED *pulRetval)
  262. {
  263. PSSTREAM_VCALL (ReadAt (ulOffset, pBuffer, ulCount, pulRetval));
  264. }
  265. //+--------------------------------------------------------------
  266. //
  267. // Member: PSStream::WriteAt, public
  268. //
  269. // Synopsis: calls to derived object
  270. //
  271. // History: 20-Jan-98 HenryLee Created
  272. //
  273. //---------------------------------------------------------------
  274. SCODE PSStream::WriteAt(
  275. #ifdef LARGE_STREAMS
  276. ULONGLONG ulOffset,
  277. #else
  278. ULONG ulOffset,
  279. #endif
  280. VOID const *pBuffer,
  281. ULONG ulCount,
  282. ULONG STACKBASED *pulRetval)
  283. {
  284. PSSTREAM_VCALL (WriteAt (ulOffset, pBuffer, ulCount, pulRetval));
  285. }
  286. //+--------------------------------------------------------------
  287. //
  288. // Member: PSStream::SetSize, public
  289. //
  290. // Synopsis: calls to derived object
  291. //
  292. // History: 20-Jan-98 HenryLee Created
  293. //
  294. //---------------------------------------------------------------
  295. #ifdef LARGE_STREAMS
  296. SCODE PSStream::SetSize(ULONGLONG ulNewSize)
  297. #else
  298. SCODE PSStream::SetSize(ULONG ulNewSize)
  299. #endif
  300. {
  301. PSSTREAM_VCALL (SetSize (ulNewSize));
  302. }
  303. //+--------------------------------------------------------------
  304. //
  305. // Member: PSStream::GetSize, public
  306. //
  307. // Synopsis: calls to derived object
  308. //
  309. // History: 20-Jan-98 HenryLee Created
  310. //
  311. //---------------------------------------------------------------
  312. #ifdef LARGE_STREAMS
  313. void PSStream::GetSize(ULONGLONG *pulSize)
  314. #else
  315. void PSStream::GetSize(ULONG *pulSize)
  316. #endif
  317. {
  318. if (_sig == CDIRECTSTREAM_SIG)
  319. ((CDirectStream *)this)->GetSize (pulSize);
  320. else if (_sig == CTRANSACTEDSTREAM_SIG)
  321. ((CTransactedStream *)this)->GetSize (pulSize);
  322. else olAssert (!"Invalid signature on PSStream!");
  323. return;
  324. }
  325. //+--------------------------------------------------------------
  326. //
  327. // Member: PDocFile::DestroyEntry, public
  328. //
  329. // Synopsis: calls to derived object
  330. //
  331. // History: 20-Jan-98 HenryLee Created
  332. //
  333. //---------------------------------------------------------------
  334. SCODE PDocFile::DestroyEntry(CDfName const *pdfnName,
  335. BOOL fClean)
  336. {
  337. PDOCFILE_VCALL (DestroyEntry(pdfnName, fClean));
  338. }
  339. //+--------------------------------------------------------------
  340. //
  341. // Member: PDocFile::RenameEntry, public
  342. //
  343. // Synopsis: calls to derived object
  344. //
  345. // History: 20-Jan-98 HenryLee Created
  346. //
  347. //---------------------------------------------------------------
  348. SCODE PDocFile::RenameEntry(CDfName const *pdfnName,
  349. CDfName const *pdfnNewName)
  350. {
  351. PDOCFILE_VCALL (RenameEntry (pdfnName, pdfnNewName));
  352. }
  353. //+--------------------------------------------------------------
  354. //
  355. // Member: PDocFile::GetClass, public
  356. //
  357. // Synopsis: calls to derived object
  358. //
  359. // History: 20-Jan-98 HenryLee Created
  360. //
  361. //---------------------------------------------------------------
  362. SCODE PDocFile::GetClass(CLSID *pclsid)
  363. {
  364. PDOCFILE_VCALL (GetClass (pclsid));
  365. }
  366. //+--------------------------------------------------------------
  367. //
  368. // Member: PDocFile::SetClass, public
  369. //
  370. // Synopsis: calls to derived object
  371. //
  372. // History: 20-Jan-98 HenryLee Created
  373. //
  374. //---------------------------------------------------------------
  375. SCODE PDocFile::SetClass(REFCLSID clsid)
  376. {
  377. PDOCFILE_VCALL (SetClass (clsid));
  378. }
  379. //+--------------------------------------------------------------
  380. //
  381. // Member: PDocFile::GetStateBits, public
  382. //
  383. // Synopsis: calls to derived object
  384. //
  385. // History: 20-Jan-98 HenryLee Created
  386. //
  387. //---------------------------------------------------------------
  388. SCODE PDocFile::GetStateBits(DWORD *pgrfStateBits)
  389. {
  390. PDOCFILE_VCALL (GetStateBits (pgrfStateBits));
  391. }
  392. //+--------------------------------------------------------------
  393. //
  394. // Member: PDocFile::SetStateBits, public
  395. //
  396. // Synopsis: calls to derived object
  397. //
  398. // History: 20-Jan-98 HenryLee Created
  399. //
  400. //---------------------------------------------------------------
  401. SCODE PDocFile::SetStateBits(DWORD grfStateBits, DWORD grfMask)
  402. {
  403. PDOCFILE_VCALL (SetStateBits (grfStateBits, grfMask));
  404. }
  405. //+--------------------------------------------------------------
  406. //
  407. // Member: PDocFile::CreateDocFile, public
  408. //
  409. // Synopsis: calls to derived object
  410. //
  411. // History: 20-Jan-98 HenryLee Created
  412. //
  413. //---------------------------------------------------------------
  414. SCODE PDocFile::CreateDocFile(CDfName const *pdfnName,
  415. DFLAGS const df,
  416. DFLUID luidSet,
  417. PDocFile **ppdfDocFile)
  418. {
  419. PDOCFILE_VCALL (CreateDocFile (pdfnName, df, luidSet, ppdfDocFile));
  420. }
  421. //+--------------------------------------------------------------
  422. //
  423. // Member: PDocFile::GetDocFile, public
  424. //
  425. // Synopsis: calls to derived object
  426. //
  427. // History: 20-Jan-98 HenryLee Created
  428. //
  429. //---------------------------------------------------------------
  430. SCODE PDocFile::GetDocFile(CDfName const *pdfnName,
  431. DFLAGS const df,
  432. PDocFile **ppdfDocFile)
  433. {
  434. PDOCFILE_VCALL (GetDocFile (pdfnName, df, ppdfDocFile));
  435. }
  436. //+--------------------------------------------------------------
  437. //
  438. // Member: PDocFile::CreateStream, public
  439. //
  440. // Synopsis: calls to derived object
  441. //
  442. // History: 20-Jan-98 HenryLee Created
  443. //
  444. //---------------------------------------------------------------
  445. SCODE PDocFile::CreateStream(CDfName const *pdfnName,
  446. DFLAGS const df,
  447. DFLUID luidSet,
  448. PSStream **ppsstStream)
  449. {
  450. PDOCFILE_VCALL (CreateStream (pdfnName, df, luidSet, ppsstStream));
  451. }
  452. //+--------------------------------------------------------------
  453. //
  454. // Member: PDocFile::GetStream, public
  455. //
  456. // Synopsis: calls to derived object
  457. //
  458. // History: 20-Jan-98 HenryLee Created
  459. //
  460. //---------------------------------------------------------------
  461. SCODE PDocFile::GetStream(CDfName const *pdfnName,
  462. DFLAGS const df,
  463. PSStream **ppsstStream)
  464. {
  465. PDOCFILE_VCALL (GetStream (pdfnName, df, ppsstStream));
  466. }
  467. //+--------------------------------------------------------------
  468. //
  469. // Member: PDocFile::FindGreaterEntry, public
  470. //
  471. // Synopsis: calls to derived object
  472. //
  473. // History: 20-Jan-98 HenryLee Created
  474. //
  475. //---------------------------------------------------------------
  476. SCODE PDocFile::FindGreaterEntry(CDfName const *pdfnKey,
  477. SIterBuffer *pib,
  478. STATSTGW *pstat)
  479. {
  480. PDOCFILE_VCALL (FindGreaterEntry (pdfnKey, pib, pstat));
  481. }
  482. //+--------------------------------------------------------------
  483. //
  484. // Member: PDocFile::StatEntry, public
  485. //
  486. // Synopsis: calls to derived object
  487. //
  488. // History: 20-Jan-98 HenryLee Created
  489. //
  490. //---------------------------------------------------------------
  491. SCODE PDocFile::StatEntry(CDfName const *pdfn,
  492. SIterBuffer *pib,
  493. STATSTGW *pstat)
  494. {
  495. PDOCFILE_VCALL (StatEntry (pdfn, pib, pstat));
  496. }
  497. //+--------------------------------------------------------------
  498. //
  499. // Member: PDocFile::BeginCommitFromChild, public
  500. //
  501. // Synopsis: calls to derived object
  502. //
  503. // History: 20-Jan-98 HenryLee Created
  504. //
  505. //---------------------------------------------------------------
  506. SCODE PDocFile::BeginCommitFromChild(CUpdateList &ulChanged,
  507. DWORD const dwFlags,
  508. CWrappedDocFile *pdfChild)
  509. {
  510. PDOCFILE_VCALL (BeginCommitFromChild (ulChanged, dwFlags, pdfChild));
  511. }
  512. //+--------------------------------------------------------------
  513. //
  514. // Member: PDocFile::EndCommitFromChild, public
  515. //
  516. // Synopsis: calls to derived object
  517. //
  518. // History: 20-Jan-98 HenryLee Created
  519. //
  520. //---------------------------------------------------------------
  521. void PDocFile::EndCommitFromChild(DFLAGS const df,
  522. CWrappedDocFile *pdfChild)
  523. {
  524. if (_sig == CDOCFILE_SIG)
  525. ((CDocFile *)this)->EndCommitFromChild (df, pdfChild);
  526. else if (_sig == CWRAPPEDDOCFILE_SIG)
  527. ((CWrappedDocFile *)this)->EndCommitFromChild (df, pdfChild);
  528. else olAssert (!"Invalid signature on PTimeEntry!");
  529. return;
  530. }
  531. //+--------------------------------------------------------------
  532. //
  533. // Member: PDocFile::IsEntry, public
  534. //
  535. // Synopsis: calls to derived object
  536. //
  537. // History: 20-Jan-98 HenryLee Created
  538. //
  539. //---------------------------------------------------------------
  540. SCODE PDocFile::IsEntry(CDfName const *pdfnName,
  541. SEntryBuffer *peb)
  542. {
  543. PDOCFILE_VCALL (IsEntry (pdfnName, peb));
  544. }
  545. //+--------------------------------------------------------------
  546. //
  547. // Member: PDocFile::DeleteContents, public
  548. //
  549. // Synopsis: calls to derived object
  550. //
  551. // History: 20-Jan-98 HenryLee Created
  552. //
  553. //---------------------------------------------------------------
  554. SCODE PDocFile::DeleteContents(void)
  555. {
  556. PDOCFILE_VCALL (DeleteContents());
  557. }