-
Notifications
You must be signed in to change notification settings - Fork 4.6k
/
stgtiggerstream.h
111 lines (84 loc) · 2.62 KB
/
stgtiggerstream.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
//*****************************************************************************
// StgTiggerStream.h
//
//
// TiggerStream is the companion to the TiggerStorage CoClass. It handles the
// streams managed inside of the storage and does the direct file i/o.
//
//*****************************************************************************
#ifndef __StgTiggerStream_h__
#define __StgTiggerStream_h__
#include "stgtiggerstorage.h" // Data definitions.
enum
{
STREAM_DATA_NAME
};
class TiggerStorage;
class TiggerStream :
public IStream
{
public:
TiggerStream() :
m_pStorage(0),
m_cRef(1)
{}
virtual ~TiggerStream() {}
virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, PVOID *pp)
{ return (BadError(E_NOTIMPL)); }
virtual ULONG STDMETHODCALLTYPE AddRef()
{ return InterlockedIncrement(&m_cRef); }
virtual ULONG STDMETHODCALLTYPE Release()
{
ULONG cRef;
if ((cRef = InterlockedDecrement(&m_cRef)) == 0)
delete this;
return (cRef);
}
// IStream
virtual HRESULT STDMETHODCALLTYPE Read(
void *pv,
ULONG cb,
ULONG *pcbRead);
virtual HRESULT STDMETHODCALLTYPE Write(
const void *pv,
ULONG cb,
ULONG *pcbWritten);
virtual HRESULT STDMETHODCALLTYPE Seek(
LARGE_INTEGER dlibMove,
DWORD dwOrigin,
ULARGE_INTEGER *plibNewPosition);
virtual HRESULT STDMETHODCALLTYPE SetSize(
ULARGE_INTEGER libNewSize);
virtual HRESULT STDMETHODCALLTYPE CopyTo(
IStream *pstm,
ULARGE_INTEGER cb,
ULARGE_INTEGER *pcbRead,
ULARGE_INTEGER *pcbWritten);
virtual HRESULT STDMETHODCALLTYPE Commit(
DWORD grfCommitFlags);
virtual HRESULT STDMETHODCALLTYPE Revert( void);
virtual HRESULT STDMETHODCALLTYPE LockRegion(
ULARGE_INTEGER libOffset,
ULARGE_INTEGER cb,
DWORD dwLockType);
virtual HRESULT STDMETHODCALLTYPE UnlockRegion(
ULARGE_INTEGER libOffset,
ULARGE_INTEGER cb,
DWORD dwLockType);
virtual HRESULT STDMETHODCALLTYPE Stat(
STATSTG *pstatstg,
DWORD grfStatFlag);
virtual HRESULT STDMETHODCALLTYPE Clone(
IStream **ppstm);
HRESULT Init( // Return code.
TiggerStorage *pStorage, // Parent storage.
LPCSTR szStream); // Stream name.
ULONG GetStreamSize();
private:
TiggerStorage *m_pStorage; // Our parent storage.
char m_rcStream[MAXSTREAMNAME]; // Name of the stream.
LONG m_cRef; // Ref count.
};
#endif // __StgTiggerStream_h__