1 | // Licensed to the .NET Foundation under one or more agreements. |
2 | // The .NET Foundation licenses this file to you under the MIT license. |
3 | // See the LICENSE file in the project root for more information. |
4 | |
5 | |
6 | #ifndef __FSTREAM_H_INCLUDED__ |
7 | #define __FSTREAM_H_INCLUDED__ |
8 | |
9 | #include <objidl.h> |
10 | |
11 | class CFileStream : public IStream |
12 | { |
13 | public: |
14 | CFileStream(); |
15 | virtual ~CFileStream(); |
16 | |
17 | HRESULT OpenForRead(LPCWSTR wzFilePath); |
18 | HRESULT OpenForWrite(LPCWSTR wzFilePath); |
19 | |
20 | // IUnknown methods: |
21 | STDMETHODIMP_(ULONG) AddRef(); |
22 | STDMETHODIMP_(ULONG) Release(); |
23 | STDMETHODIMP QueryInterface(REFIID riid, LPVOID *ppvObj); |
24 | |
25 | // ISequentialStream methods: |
26 | STDMETHODIMP Read(void *pv, ULONG cb, ULONG *pcbRead); |
27 | STDMETHODIMP Write(void const *pv, ULONG cb, ULONG *pcbWritten); |
28 | |
29 | // IStream methods: |
30 | STDMETHODIMP Seek(LARGE_INTEGER dlibMove, DWORD dwOrigin, ULARGE_INTEGER *plibNewPosition); |
31 | STDMETHODIMP SetSize(ULARGE_INTEGER libNewSize); |
32 | STDMETHODIMP CopyTo(IStream *pstm, ULARGE_INTEGER cb, ULARGE_INTEGER *pcbRead, ULARGE_INTEGER *pcbWritten); |
33 | STDMETHODIMP Commit(DWORD grfCommitFlags); |
34 | STDMETHODIMP Revert(); |
35 | STDMETHODIMP LockRegion(ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType); |
36 | STDMETHODIMP UnlockRegion(ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType); |
37 | STDMETHODIMP Stat(STATSTG *pstatstg, DWORD grfStatFlag); |
38 | STDMETHODIMP Clone(IStream **ppIStream); |
39 | |
40 | private: |
41 | BOOL Close(); |
42 | |
43 | private: |
44 | LONG _cRef; |
45 | HANDLE _hFile; |
46 | |
47 | }; |
48 | |
49 | #endif |
50 | |
51 | |