-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathVirtualStream.h
69 lines (47 loc) · 1.53 KB
/
VirtualStream.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
#ifndef VIRTUALSTREAM_H
#define VIRTUALSTREAM_H
#include "IVirtualStream.h"
#include <stdio.h>
//--------------------------
// CMemoryStream - File stream
//--------------------------
class CMemoryStream : public IVirtualStream
{
public:
CMemoryStream();
~CMemoryStream();
// reads data from virtual stream
size_t Read(void *dest, size_t count, size_t size);
// writes data to virtual stream
size_t Write(const void *src, size_t count, size_t size);
// seeks pointer to position
int Seek(long nOffset, VirtStreamSeek_e seekType);
// returns current pointer position
long Tell();
// returns memory allocated for this stream
long GetSize();
// opens stream, if this is a file, data is filename
bool Open(ubyte* data, int nOpenFlags, int nDataSize);
// closes stream
void Close();
// flushes stream, doesn't affects on memory stream
int Flush();
VirtStreamType_e GetType() { return m_pStart ? VS_TYPE_MEMORY : VS_TYPE_INVALID; }
// reads file to this stream
bool ReadFromFileStream( FILE* pFile );
// saves stream to file for stream (only for memory stream )
void WriteToFileStream( FILE* pFile );
// returns current pointer to the stream (only memory stream)
ubyte* GetCurrentPointer();
// returns base pointer to the stream (only memory stream)
ubyte* GetBasePointer();
protected:
// reallocates memory
void ReAllocate(long nNewSize);
private:
ubyte* m_pStart;
ubyte* m_pCurrent;
long m_nAllocatedSize;
long m_nUsageFlags;
};
#endif // VIRTUALSTREAM_H