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.

108 lines
2.8 KiB

  1. //+--------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1991 - 1996.
  5. //
  6. // File: dfstream.cxx
  7. //
  8. // Contents: Implementations of CDocFile stream methods
  9. //
  10. //---------------------------------------------------------------
  11. #include "dfhead.cxx"
  12. #include "h/sstream.hxx"
  13. //+--------------------------------------------------------------
  14. //
  15. // Method: CDocFile::CreateStream, public
  16. //
  17. // Synopsis: Creates a named stream in a DocFile
  18. //
  19. // Arguments: [pwcsName] - Name of the stream
  20. // [df] - Transactioning flags
  21. // [dlSet] - LUID to set or DF_NOLUID
  22. // [ppstStream] - Pointer to storage for the stream pointer
  23. //
  24. // Returns: Appropriate error code
  25. //
  26. // Modifies: [ppstStream]
  27. //
  28. //---------------------------------------------------------------
  29. SCODE CDocFile::CreateStream(CDfName const *pdfn,
  30. DFLAGS const df,
  31. DFLUID dlSet,
  32. CDirectStream **ppstStream)
  33. {
  34. SCODE sc;
  35. CDirectStream *pstm;
  36. olDebugOut((DEB_ITRACE, "In CDocFile::CreateStream("
  37. "%ws, %X, %lu, %p)\n",
  38. pdfn, df, dlSet, ppstStream));
  39. UNREFERENCED_PARM(df);
  40. if (dlSet == DF_NOLUID)
  41. dlSet = CDirectStream::GetNewLuid();
  42. olMem(pstm = new CDirectStream(dlSet));
  43. olChkTo(EH_pstm, pstm->Init(&_stgh, pdfn, TRUE));
  44. *ppstStream = pstm;
  45. olDebugOut((DEB_ITRACE, "Out CDocFile::CreateStream => %p\n",
  46. *ppstStream));
  47. return S_OK;
  48. EH_pstm:
  49. delete pstm;
  50. EH_Err:
  51. return sc;
  52. }
  53. //+--------------------------------------------------------------
  54. //
  55. // Method: CDocFile::GetStream, public
  56. //
  57. // Synopsis: Retrieves an existing stream from a DocFile
  58. //
  59. // Arguments: [pwcsName] - Name of the stream
  60. // [df] - Transactioning flags
  61. // [dwType] - Type of entry
  62. // [ppstStream] - Pointer to storage for the stream pointer
  63. //
  64. // Returns: Appropriate error code
  65. //
  66. // Modifies: [ppstStream]
  67. //
  68. //---------------------------------------------------------------
  69. SCODE CDocFile::GetStream(CDfName const *pdfn,
  70. DFLAGS const df,
  71. CDirectStream **ppstStream)
  72. {
  73. SCODE sc;
  74. CDirectStream *pstm;
  75. olDebugOut((DEB_ITRACE, "In CDocFile::GetStream(%ws, %X, %p)\n",
  76. pdfn, df, ppstStream));
  77. UNREFERENCED_PARM(df);
  78. DFLUID dl = CDirectStream::GetNewLuid();
  79. olMem(pstm = new CDirectStream(dl));
  80. olChkTo(EH_pstm, pstm->Init(&_stgh, pdfn, FALSE));
  81. *ppstStream = pstm;
  82. olDebugOut((DEB_ITRACE, "Out CDocFile::GetStream => %p\n",
  83. *ppstStream));
  84. return S_OK;
  85. EH_pstm:
  86. delete pstm;
  87. EH_Err:
  88. return sc;
  89. }