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.

135 lines
3.5 KiB

  1. //+--------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1991 - 1992.
  5. //
  6. // File: dfstream.cxx
  7. //
  8. // Contents: Implementations of CDocFile stream methods
  9. //
  10. // History: 18-Oct-91 DrewB Created
  11. //
  12. //---------------------------------------------------------------
  13. #include <dfhead.cxx>
  14. #pragma hdrstop
  15. //+--------------------------------------------------------------
  16. //
  17. // Method: CDocFile::CreateStream, public
  18. //
  19. // Synopsis: Creates a named stream in a DocFile
  20. //
  21. // Arguments: [pwcsName] - Name of the stream
  22. // [df] - Transactioning flags
  23. // [dlSet] - LUID to set or DF_NOLUID
  24. // [dwType] - Type of entry to be created
  25. // [ppsstStream] - Pointer to storage for the stream pointer
  26. //
  27. // Returns: Appropriate error code
  28. //
  29. // Modifies: [ppsstStream]
  30. //
  31. // History: 22-Aug-91 DrewB Created
  32. //
  33. //---------------------------------------------------------------
  34. #ifdef CODESEGMENTS
  35. #pragma code_seg(SEG_CDocFile_CreateStream) // Dirdf_Create_TEXT
  36. #endif
  37. SCODE CDocFile::CreateStream(CDfName const *pdfn,
  38. DFLAGS const df,
  39. DFLUID dlSet,
  40. PSStream **ppsstStream)
  41. {
  42. SCODE sc;
  43. CDirectStream *pstm;
  44. olDebugOut((DEB_ITRACE, "In CDocFile::CreateStream("
  45. "%ws, %X, %lu, %p)\n",
  46. pdfn, df, dlSet, ppsstStream));
  47. UNREFERENCED_PARM(df);
  48. if (dlSet == DF_NOLUID)
  49. dlSet = CDirectStream::GetNewLuid(_pdfb->GetMalloc());
  50. #ifndef REF
  51. pstm = new (BP_TO_P(CDFBasis *, _pdfb)) CDirectStream(dlSet);
  52. olAssert(pstm != NULL && aMsg("Reserved stream unavailable"));
  53. #else
  54. olMem(pstm = new CDirectStream(dlSet));
  55. #endif //!REF
  56. olChkTo(EH_pstm, pstm->Init(&_stgh, pdfn, TRUE));
  57. *ppsstStream = pstm;
  58. olDebugOut((DEB_ITRACE, "Out CDocFile::CreateStream => %p\n",
  59. *ppsstStream));
  60. return S_OK;
  61. EH_pstm:
  62. #ifndef REF
  63. pstm->ReturnToReserve(BP_TO_P(CDFBasis *, _pdfb));
  64. #else
  65. delete pstm;
  66. EH_Err:
  67. #endif //!REF
  68. return sc;
  69. }
  70. //+--------------------------------------------------------------
  71. //
  72. // Method: CDocFile::GetStream, public
  73. //
  74. // Synopsis: Retrieves an existing stream from a DocFile
  75. //
  76. // Arguments: [pwcsName] - Name of the stream
  77. // [df] - Transactioning flags
  78. // [dwType] - Type of entry
  79. // [ppsstStream] - Pointer to storage for the stream pointer
  80. //
  81. // Returns: Appropriate error code
  82. //
  83. // Modifies: [ppsstStream]
  84. //
  85. // History: 22-Aug-91 DrewB Created
  86. //
  87. //---------------------------------------------------------------
  88. #ifdef CODESEGMENTS
  89. #pragma code_seg(SEG_CDocFile_GetStream) // Dirdf_Open_TEXT
  90. #endif
  91. SCODE CDocFile::GetStream(CDfName const *pdfn,
  92. DFLAGS const df,
  93. PSStream **ppsstStream)
  94. {
  95. SCODE sc;
  96. CDirectStream *pstm;
  97. olDebugOut((DEB_ITRACE, "In CDocFile::GetStream(%ws, %X, %p)\n",
  98. pdfn, df, ppsstStream));
  99. UNREFERENCED_PARM(df);
  100. DFLUID dl = CDirectStream::GetNewLuid(_pdfb->GetMalloc());
  101. #ifndef REF
  102. olMem(pstm = new(_pdfb->GetMalloc()) CDirectStream(dl));
  103. #else
  104. olMem(pstm = new CDirectStream(dl));
  105. #endif //!REF
  106. olChkTo(EH_pstm, pstm->Init(&_stgh, pdfn, FALSE));
  107. *ppsstStream = pstm;
  108. olDebugOut((DEB_ITRACE, "Out CDocFile::GetStream => %p\n",
  109. *ppsstStream));
  110. return S_OK;
  111. EH_pstm:
  112. delete pstm;
  113. EH_Err:
  114. return sc;
  115. }