forked from hitmen047/Source-PlusPlus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutlstreambuffer.h
71 lines (52 loc) · 1.65 KB
/
utlstreambuffer.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
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
// $NoKeywords: $
//
// Serialization/unserialization buffer
//=============================================================================//
#ifndef UTLSTREAMBUFFER_H
#define UTLSTREAMBUFFER_H
#ifdef _WIN32
#pragma once
#endif
#include "tier1/utlbuffer.h"
#include "filesystem.h"
//-----------------------------------------------------------------------------
// Command parsing..
//-----------------------------------------------------------------------------
class CUtlStreamBuffer : public CUtlBuffer
{
typedef CUtlBuffer BaseClass;
public:
// See CUtlBuffer::BufferFlags_t for flags
CUtlStreamBuffer( );
CUtlStreamBuffer( const char *pFileName, const char *pPath, int nFlags = 0, bool bDelayOpen = false );
~CUtlStreamBuffer();
// Open the file. normally done in constructor
void Open( const char *pFileName, const char *pPath, int nFlags );
// close the file. normally done in destructor
void Close();
// Is the file open?
bool IsOpen() const;
private:
// error flags
enum
{
FILE_OPEN_ERROR = MAX_ERROR_FLAG << 1,
FILE_WRITE_ERROR = MAX_ERROR_FLAG << 2,
};
// Overflow functions
bool StreamPutOverflow( int nSize );
bool StreamGetOverflow( int nSize );
// Grow allocation size to fit requested size
void GrowAllocatedSize( int nSize );
// Reads bytes from the file; fixes up maxput if necessary and null terminates
int ReadBytesFromFile( int nBytesToRead, int nReadOffset );
FileHandle_t OpenFile( const char *pFileName, const char *pPath );
FileHandle_t m_hFileHandle;
char *m_pFileName;
char *m_pPath;
};
#endif // UTLSTREAMBUFFER_H