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.

127 lines
2.8 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1994.
  5. //
  6. // File: simpdf.cxx
  7. //
  8. // Contents: StdDocfile implementation
  9. //
  10. // Classes:
  11. //
  12. // Functions:
  13. //
  14. // History: 04-Aug-94 PhilipLa Created
  15. //
  16. //----------------------------------------------------------------------------
  17. #include "simphead.cxx"
  18. #pragma hdrstop
  19. #if DBG == 1
  20. DECLARE_INFOLEVEL(simp)
  21. #endif
  22. //+---------------------------------------------------------------------------
  23. //
  24. // Function: DfCreateSimpDocfile, private
  25. //
  26. // Synopsis:
  27. //
  28. // Arguments:
  29. //
  30. // Returns: Appropriate status code
  31. //
  32. // Modifies:
  33. //
  34. // History: 04-Aug-94 PhilipLa Created
  35. //
  36. // Notes:
  37. //
  38. //----------------------------------------------------------------------------
  39. SCODE DfCreateSimpDocfile(WCHAR const *pwcsName,
  40. DWORD grfMode,
  41. DWORD reserved,
  42. IStorage **ppstgOpen)
  43. {
  44. SCODE sc;
  45. CSimpStorage *pstg;
  46. if (grfMode !=
  47. (STGM_SIMPLE | STGM_READWRITE | STGM_SHARE_EXCLUSIVE | STGM_CREATE))
  48. return STG_E_INVALIDFLAG;
  49. pstg = new CSimpStorage;
  50. if (pstg == NULL)
  51. {
  52. return STG_E_INSUFFICIENTMEMORY;
  53. }
  54. sc = pstg->Init(pwcsName, NULL);
  55. if (FAILED(sc))
  56. {
  57. pstg->Release();
  58. pstg = NULL;
  59. }
  60. *ppstgOpen = pstg;
  61. return sc;
  62. }
  63. #if WIN32 != 200
  64. //+---------------------------------------------------------------------------
  65. //
  66. // Function: DfOpenSimpDocfile, private
  67. //
  68. // Synopsis: opens an existing docfile for reading
  69. //
  70. // Arguments: [pwcsName] name of docfile
  71. // [grfMode] permission bits
  72. // [reserved] must be zero
  73. // [pstgOpen] opened storage pointer
  74. //
  75. // Returns: Appropriate status code
  76. //
  77. // History: 04-Aug-96 HenryLee Created
  78. //
  79. // Notes:
  80. //
  81. //----------------------------------------------------------------------------
  82. SCODE DfOpenSimpDocfile(WCHAR const *pwcsName,
  83. DWORD grfMode,
  84. DWORD reserved,
  85. IStorage **ppstgOpen)
  86. {
  87. SCODE sc = S_OK;
  88. CSimpStorageOpen *pstg;
  89. if (ppstgOpen == NULL)
  90. return STG_E_INVALIDPARAMETER;
  91. else
  92. *ppstgOpen = NULL;
  93. if (grfMode != (STGM_SIMPLE | STGM_READWRITE | STGM_SHARE_EXCLUSIVE) &&
  94. grfMode != (STGM_SIMPLE | STGM_READ | STGM_SHARE_EXCLUSIVE))
  95. return STG_E_INVALIDFLAG;
  96. if ((pstg = new CSimpStorageOpen) == NULL)
  97. {
  98. return STG_E_INSUFFICIENTMEMORY;
  99. }
  100. if (FAILED(sc = pstg->Init(pwcsName, grfMode, NULL)))
  101. {
  102. pstg->Release();
  103. pstg = NULL;
  104. }
  105. *ppstgOpen = pstg;
  106. return sc;
  107. }
  108. #endif // WIN32 != 200