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.

120 lines
3.2 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1993.
  5. //
  6. // File: filstm.hxx
  7. //
  8. // Contents: CNtFileStream header
  9. //
  10. // Classes: CNtFileStream
  11. //
  12. // History: 28-Jun-93 DrewB Created
  13. //
  14. // Notes: Non-OFS
  15. //
  16. //----------------------------------------------------------------------------
  17. #ifndef __FILSTM_HXX__
  18. #define __FILSTM_HXX__
  19. #include <otrack.hxx>
  20. #include <overlap.hxx>
  21. //+---------------------------------------------------------------------------
  22. //
  23. // Class: CNtFileStream (fs)
  24. //
  25. // Purpose: Implements IStream for an NT handle
  26. //
  27. // Interface: IStream
  28. //
  29. // History: 28-Jun-93 DrewB Created
  30. //
  31. //----------------------------------------------------------------------------
  32. interface CNtFileStream
  33. : INHERIT_TRACKING,
  34. //public IStream,
  35. public COverlappedStream
  36. {
  37. public:
  38. CNtFileStream(void);
  39. SCODE InitFromHandle(HANDLE h,
  40. DWORD grfMode,
  41. CREATEOPEN co,
  42. LPSTGSECURITY pssSecurity);
  43. SCODE InitFromPath(HANDLE hParent,
  44. const WCHAR *pwcsName,
  45. DWORD grfMode,
  46. DWORD grfAttr,
  47. CREATEOPEN co,
  48. LPSTGSECURITY pssSecurity);
  49. SCODE InitClone(HANDLE h,
  50. DWORD grfMode);
  51. ~CNtFileStream(void);
  52. // IUnknown
  53. STDMETHOD(QueryInterface)(REFIID iid, void **ppvObj);
  54. DECLARE_STD_REFCOUNTING;
  55. // IStream
  56. STDMETHOD(Read)(VOID *pv,
  57. ULONG cb,
  58. ULONG *pcbRead);
  59. STDMETHOD(Write)(VOID const *pv,
  60. ULONG cb,
  61. ULONG *pcbWritten);
  62. STDMETHOD(Seek)(LARGE_INTEGER dlibMove,
  63. DWORD dwOrigin,
  64. ULARGE_INTEGER *plibNewPosition);
  65. STDMETHOD(SetSize)(ULARGE_INTEGER cb);
  66. STDMETHOD(CopyTo)(IStream *pstm,
  67. ULARGE_INTEGER cb,
  68. ULARGE_INTEGER *pcbRead,
  69. ULARGE_INTEGER *pcbWritten);
  70. STDMETHOD(Commit)(DWORD grfCommitFlags);
  71. STDMETHOD(Revert)(void);
  72. STDMETHOD(LockRegion)(ULARGE_INTEGER libOffset,
  73. ULARGE_INTEGER cb,
  74. DWORD dwLockType);
  75. STDMETHOD(UnlockRegion)(ULARGE_INTEGER libOffset,
  76. ULARGE_INTEGER cb,
  77. DWORD dwLockType);
  78. STDMETHOD(Stat)(STATSTG *pstatstg, DWORD grfStatFlag);
  79. STDMETHOD(Clone)(IStream **ppstm);
  80. private:
  81. inline SCODE Validate(void) const;
  82. SCODE ValidateMode(DWORD grfMode);
  83. SCODE InitCommon(CREATEOPEN co);
  84. //NuSafeNtHandle _h; // moved to COverlappedStream
  85. ULONG _sig;
  86. DWORD _grfMode;
  87. };
  88. SAFE_INTERFACE_PTR(SafeCNtFileStream, CNtFileStream);
  89. #define CNTFILESTREAM_SIG LONGSIG('F', 'S', 'T', 'M')
  90. #define CNTFILESTREAM_SIGDEL LONGSIG('F', 's', 'T', 'm')
  91. //+--------------------------------------------------------------
  92. //
  93. // Member: CNtFileStream::Validate, private
  94. //
  95. // Synopsis: Validates the class signature
  96. //
  97. // Returns: Returns STG_E_INVALIDHANDLE for failure
  98. //
  99. // History: 28-Jun-93 DrewB Created
  100. //
  101. //---------------------------------------------------------------
  102. inline SCODE CNtFileStream::Validate(void) const
  103. {
  104. return (this == NULL || _sig != CNTFILESTREAM_SIG) ?
  105. STG_E_INVALIDHANDLE : S_OK;
  106. }
  107. #endif // #ifndef __FILSTM_HXX__