summaryrefslogtreecommitdiff
path: root/public/tier2/utlstreambuffer.h
diff options
context:
space:
mode:
authorFluorescentCIAAfricanAmerican <[email protected]>2020-04-22 12:56:21 -0400
committerFluorescentCIAAfricanAmerican <[email protected]>2020-04-22 12:56:21 -0400
commit3bf9df6b2785fa6d951086978a3e66f49427166a (patch)
tree2c0f1f0c63c4832882bc93814ebd2c2b1c6224e5 /public/tier2/utlstreambuffer.h
downloadarchived-source-engine-2018-hl2-src-master.tar.xz
archived-source-engine-2018-hl2-src-master.zip
Diffstat (limited to 'public/tier2/utlstreambuffer.h')
-rw-r--r--public/tier2/utlstreambuffer.h71
1 files changed, 71 insertions, 0 deletions
diff --git a/public/tier2/utlstreambuffer.h b/public/tier2/utlstreambuffer.h
new file mode 100644
index 0000000..d1d9c11
--- /dev/null
+++ b/public/tier2/utlstreambuffer.h
@@ -0,0 +1,71 @@
+//========= 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
+