-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathStorageImpl.h
237 lines (177 loc) · 6.99 KB
/
StorageImpl.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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
//---------------------------------------------------------------------------
/*
TVP2 ( T Visual Presenter 2 ) A script authoring tool
Copyright (C) 2000 W.Dee <[email protected]> and contributors
See details of license at "license.txt"
*/
//---------------------------------------------------------------------------
// Universal Storage System
//---------------------------------------------------------------------------
#ifndef StorageImplH
#define StorageImplH
//---------------------------------------------------------------------------
#include "StorageIntf.h"
#include "UtilStreams.h"
#include <objidl.h> // for IStream
//---------------------------------------------------------------------------
// Susie plug-in related
//---------------------------------------------------------------------------
void TVPLoadArchiveSPI(HINSTANCE inst);
void TVPUnloadArchiveSPI(HINSTANCE inst);
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// tTVPLocalFileStream
//---------------------------------------------------------------------------
class tTVPLocalFileStream : public tTJSBinaryStream
{
private:
HANDLE Handle;
public:
tTVPLocalFileStream(const ttstr &origname, const ttstr & localname,
tjs_uint32 flag);
~tTVPLocalFileStream();
tjs_uint64 TJS_INTF_METHOD Seek(tjs_int64 offset, tjs_int whence);
tjs_uint TJS_INTF_METHOD Read(void *buffer, tjs_uint read_size);
tjs_uint TJS_INTF_METHOD Write(const void *buffer, tjs_uint write_size);
void TJS_INTF_METHOD SetEndOfStorage();
tjs_uint64 TJS_INTF_METHOD GetSize();
HANDLE GetHandle() const { return Handle; }
};
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
TJS_EXP_FUNC_DEF(bool, TVPCheckExistentLocalFolder, (const ttstr &name));
/* name must be an OS's NATIVE folder name */
TJS_EXP_FUNC_DEF(bool, TVPCheckExistentLocalFile, (const ttstr &name));
/* name must be an OS's NATIVE file name */
TJS_EXP_FUNC_DEF(bool, TVPCreateFolders, (const ttstr &folder));
/* make folders recursively, like mkdir -p. folder must be OS NATIVE folder name */
//---------------------------------------------------------------------------
#ifdef TJS_SUPPORT_VCL
//---------------------------------------------------------------------------
// TTVPStreamAdapter
//---------------------------------------------------------------------------
/*
this class provides VCL's TStream adapter for tTJSBinaryStream
*/
class TTVPStreamAdapter : public TStream
{
private:
tTJSBinaryStream *Stream;
public:
__fastcall TTVPStreamAdapter(tTJSBinaryStream *ref);
/*
the stream passed by argument here is freed by this instance'
destruction.
*/
__fastcall ~TTVPStreamAdapter();
int __fastcall Read(void *Buffer,int Count);
// read
int __fastcall Seek(int Offset,WORD Origin);
// seek
int __fastcall Write(const void *Buffer,int Count);
__property Size;
__property Position;
};
//---------------------------------------------------------------------------
#endif
//---------------------------------------------------------------------------
// tTVPIStreamAdapter
//---------------------------------------------------------------------------
/*
this class provides COM's IStream adapter for tTJSBinaryStream
*/
class tTVPIStreamAdapter : public IStream
{
private:
tTJSBinaryStream *Stream;
ULONG RefCount;
public:
tTVPIStreamAdapter(tTJSBinaryStream *ref);
/*
the stream passed by argument here is freed by this instance'
destruction.
*/
~tTVPIStreamAdapter();
// IUnknown
HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid,
void **ppvObject);
ULONG STDMETHODCALLTYPE AddRef(void);
ULONG STDMETHODCALLTYPE Release(void);
// ISequentialStream
HRESULT STDMETHODCALLTYPE Read(void *pv, ULONG cb, ULONG *pcbRead);
HRESULT STDMETHODCALLTYPE Write(const void *pv, ULONG cb,
ULONG *pcbWritten);
// IStream
HRESULT STDMETHODCALLTYPE Seek(LARGE_INTEGER dlibMove,
DWORD dwOrigin, ULARGE_INTEGER *plibNewPosition);
HRESULT STDMETHODCALLTYPE SetSize(ULARGE_INTEGER libNewSize);
HRESULT STDMETHODCALLTYPE CopyTo(IStream *pstm, ULARGE_INTEGER cb,
ULARGE_INTEGER *pcbRead, ULARGE_INTEGER *pcbWritten);
HRESULT STDMETHODCALLTYPE Commit(DWORD grfCommitFlags);
HRESULT STDMETHODCALLTYPE Revert(void);
HRESULT STDMETHODCALLTYPE LockRegion(ULARGE_INTEGER libOffset,
ULARGE_INTEGER cb, DWORD dwLockType);
HRESULT STDMETHODCALLTYPE UnlockRegion(ULARGE_INTEGER libOffset,
ULARGE_INTEGER cb, DWORD dwLockType);
HRESULT STDMETHODCALLTYPE Stat(STATSTG *pstatstg, DWORD grfStatFlag);
HRESULT STDMETHODCALLTYPE Clone(IStream **ppstm);
void ClearStream() {
Stream = NULL;
}
};
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// IStream creator
//---------------------------------------------------------------------------
TJS_EXP_FUNC_DEF(IStream *, TVPCreateIStream, (const ttstr &name, tjs_uint32 flags));
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// tTVPBinaryStreamAdapter
//---------------------------------------------------------------------------
/*
this class provides tTJSBinaryStream adapter for IStream
*/
class tTVPBinaryStreamAdapter : public tTJSBinaryStream
{
typedef tTJSBinaryStream inherited;
private:
IStream *Stream;
public:
tTVPBinaryStreamAdapter(IStream *ref);
/*
the stream passed by argument here is freed by this instance'
destruction.
*/
~tTVPBinaryStreamAdapter();
tjs_uint64 TJS_INTF_METHOD Seek(tjs_int64 offset, tjs_int whence);
tjs_uint TJS_INTF_METHOD Read(void *buffer, tjs_uint read_size);
tjs_uint TJS_INTF_METHOD Write(const void *buffer, tjs_uint write_size);
tjs_uint64 TJS_INTF_METHOD GetSize();
void TJS_INTF_METHOD SetEndOfStorage();
};
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// tTVPBinaryStreamAdapter creator
//---------------------------------------------------------------------------
TJS_EXP_FUNC_DEF(tTJSBinaryStream *, TVPCreateBinaryStreamAdapter, (IStream *refstream));
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// tTVPPluginHolder
//---------------------------------------------------------------------------
/*
tTVPPluginHolder holds plug-in. if the plug-in is not a local storage,
plug-in is to be extracted to temporary directory and be held until
the program done using it.
*/
class tTVPPluginHolder
{
private:
ttstr LocalName;
tTVPLocalTempStorageHolder * LocalTempStorageHolder;
public:
tTVPPluginHolder(const ttstr &aname);
~tTVPPluginHolder();
const ttstr & GetLocalName() const;
};
//---------------------------------------------------------------------------
#endif