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.

146 lines
4.4 KiB

  1. //+--------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1992.
  5. //
  6. // File: pdffuncs.cxx
  7. //
  8. // Contents: PDocFile static member functions
  9. //
  10. // History: 22-Jun-92 DrewB Created
  11. //
  12. //---------------------------------------------------------------
  13. #include <dfhead.cxx>
  14. #pragma hdrstop
  15. #include <tstream.hxx>
  16. //+---------------------------------------------------------------------------
  17. //
  18. // Member: PDocFile::CreateFromUpdate, public
  19. //
  20. // Synopsis: Creates an object from an update list entry
  21. //
  22. // Arguments: [pud] - Update entry
  23. // [pdf] - Docfile
  24. // [df] - Permissions
  25. //
  26. // Returns: Appropriate status code
  27. //
  28. // History: 02-Nov-92 DrewB Created
  29. //
  30. //----------------------------------------------------------------------------
  31. SCODE PDocFile::CreateFromUpdate(CUpdate *pud,
  32. PDocFile *pdf,
  33. DFLAGS df)
  34. {
  35. PDocFile *pdfChild = NULL;
  36. PSStream *pstChild = NULL;
  37. SCODE sc;
  38. olDebugOut((DEB_ITRACE, "In PDocFile::CreateFromUpdate(%p, %p, %X)\n",
  39. pud, pdf, df));
  40. olAssert(pud->GetXSM() != NULL);
  41. switch(pud->GetFlags() & (ULF_TYPEFLAGS & STGTY_REAL))
  42. {
  43. case STGTY_STORAGE:
  44. olChk(pdf->CreateDocFile(pud->GetCurrentName(), df, pud->GetLUID(),
  45. pud->GetFlags() & ULF_TYPEFLAGS, &pdfChild));
  46. olChkTo(EH_Create,
  47. ((CWrappedDocFile *)pud->GetXSM())->SetBase(pdfChild));
  48. break;
  49. case STGTY_STREAM:
  50. olChk(pdf->CreateStream(pud->GetCurrentName(), df, pud->GetLUID(),
  51. pud->GetFlags() & ULF_TYPEFLAGS, &pstChild));
  52. olChkTo(EH_Create,
  53. ((CTransactedStream *)pud->GetXSM())->SetBase(pstChild));
  54. break;
  55. default:
  56. olAssert(FALSE && aMsg("Unknown type in update list entry"));
  57. olErr(EH_Err, STG_E_DOCFILECORRUPT);
  58. break;
  59. }
  60. olDebugOut((DEB_ITRACE, "Out PDocFile::CreateFromUpdate\n"));
  61. return S_OK;
  62. EH_Create:
  63. if ((pud->GetFlags() & (ULF_TYPEFLAGS & STGTY_REAL)) == STGTY_STORAGE)
  64. if (pdfChild)
  65. pdfChild->Release();
  66. else
  67. {
  68. olAssert((pud->GetFlags() & (ULF_TYPEFLAGS & STGTY_REAL)) ==
  69. STGTY_STREAM);
  70. if (pstChild)
  71. pstChild->Release();
  72. }
  73. olVerSucc(pdf->DestroyEntry(pud->GetCurrentName(), TRUE));
  74. EH_Err:
  75. return sc;
  76. }
  77. //+--------------------------------------------------------------
  78. //
  79. // Member: PDocFile::ExcludeEntries, public
  80. //
  81. // Synopsis: Excludes the given entries
  82. //
  83. // Arguments: [snbExclude] - Entries to exclude
  84. //
  85. // Returns: Appropriate status code
  86. //
  87. // History: 26-Mar-92 DrewB Created
  88. //
  89. //---------------------------------------------------------------
  90. SCODE PDocFile::ExcludeEntries(PDocFile *pdf,
  91. SNBW snbExclude)
  92. {
  93. PSStream *psstChild = NULL;
  94. PDocFile *pdfChild = NULL;
  95. SCODE sc;
  96. CDfName dfnKey;
  97. SIterBuffer ib;
  98. olDebugOut((DEB_ITRACE, "In PDocFile::ExcludeEntries(%p)\n",
  99. snbExclude));
  100. for (;;)
  101. {
  102. if (FAILED(pdf->FindGreaterEntry(&dfnKey, &ib, NULL)))
  103. break;
  104. dfnKey.Set(&ib.dfnName);
  105. if (NameInSNB(&ib.dfnName, snbExclude) == S_OK)
  106. {
  107. switch(REAL_STGTY(ib.type))
  108. {
  109. case STGTY_STORAGE:
  110. olChkTo(EH_pwcsName, pdf->GetDocFile(&ib.dfnName, DF_READ |
  111. DF_WRITE, ib.type,
  112. &pdfChild));
  113. olChkTo(EH_Get, pdfChild->DeleteContents());
  114. pdfChild->Release();
  115. break;
  116. case STGTY_STREAM:
  117. olChkTo(EH_pwcsName, pdf->GetStream(&ib.dfnName, DF_WRITE,
  118. ib.type, &psstChild));
  119. olChkTo(EH_Get, psstChild->SetSize(0));
  120. psstChild->Release();
  121. break;
  122. }
  123. }
  124. }
  125. olDebugOut((DEB_ITRACE, "Out ExcludeEntries\n"));
  126. return S_OK;
  127. EH_Get:
  128. if (REAL_STGTY(ib.type) == STGTY_STORAGE && pdfChild)
  129. pdfChild->Release();
  130. else if (REAL_STGTY(ib.type) == STGTY_STREAM && psstChild)
  131. psstChild->Release();
  132. EH_pwcsName:
  133. return sc;
  134. }