summaryrefslogtreecommitdiff
path: root/utils/shadercompile/cmdsink.cpp
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 /utils/shadercompile/cmdsink.cpp
downloadarchived-source-engine-2018-hl2-src-master.tar.xz
archived-source-engine-2018-hl2-src-master.zip
Diffstat (limited to 'utils/shadercompile/cmdsink.cpp')
-rw-r--r--utils/shadercompile/cmdsink.cpp114
1 files changed, 114 insertions, 0 deletions
diff --git a/utils/shadercompile/cmdsink.cpp b/utils/shadercompile/cmdsink.cpp
new file mode 100644
index 0000000..024673b
--- /dev/null
+++ b/utils/shadercompile/cmdsink.cpp
@@ -0,0 +1,114 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+// Purpose: Command sink interface implementation.
+//
+// $NoKeywords: $
+//
+//=============================================================================//
+
+#include "cmdsink.h"
+
+
+namespace CmdSink
+{
+
+// ------ implementation of CResponseFiles --------------
+
+CResponseFiles::CResponseFiles( char const *szFileResult, char const *szFileListing ) :
+ m_fResult(NULL),
+ m_fListing(NULL),
+ m_lenResult(0),
+ m_dataResult(NULL),
+ m_dataListing(NULL)
+{
+ sprintf( m_szFileResult, szFileResult );
+ sprintf( m_szFileListing, szFileListing );
+}
+
+CResponseFiles::~CResponseFiles( void )
+{
+ if ( m_fResult )
+ fclose( m_fResult );
+
+ if ( m_fListing )
+ fclose( m_fListing );
+}
+
+bool CResponseFiles::Succeeded( void )
+{
+ OpenResultFile();
+ return ( m_fResult != NULL );
+}
+
+size_t CResponseFiles::GetResultBufferLen( void )
+{
+ ReadResultFile();
+ return m_lenResult;
+}
+
+const void * CResponseFiles::GetResultBuffer( void )
+{
+ ReadResultFile();
+ return m_dataResult;
+}
+
+const char * CResponseFiles::GetListing( void )
+{
+ ReadListingFile();
+ return ( ( m_dataListing && *m_dataListing ) ? m_dataListing : NULL );
+}
+
+void CResponseFiles::OpenResultFile( void )
+{
+ if ( !m_fResult )
+ {
+ m_fResult = fopen( m_szFileResult, "rb" );
+ }
+}
+
+void CResponseFiles::ReadResultFile( void )
+{
+ if ( !m_dataResult )
+ {
+ OpenResultFile();
+
+ if ( m_fResult )
+ {
+ fseek( m_fResult, 0, SEEK_END );
+ m_lenResult = (size_t) ftell( m_fResult );
+
+ if ( m_lenResult != size_t(-1) )
+ {
+ m_bufResult.EnsureCapacity( m_lenResult );
+ fseek( m_fResult, 0, SEEK_SET );
+ fread( m_bufResult.Base(), 1, m_lenResult, m_fResult );
+ m_dataResult = m_bufResult.Base();
+ }
+ }
+ }
+}
+
+void CResponseFiles::ReadListingFile( void )
+{
+ if ( !m_dataListing )
+ {
+ if ( !m_fListing )
+ m_fListing = fopen( m_szFileListing, "rb" );
+
+ if ( m_fListing )
+ {
+ fseek( m_fListing, 0, SEEK_END );
+ size_t len = (size_t) ftell( m_fListing );
+
+ if ( len != size_t(-1) )
+ {
+ m_bufListing.EnsureCapacity( len );
+ fseek( m_fListing, 0, SEEK_SET );
+ fread( m_bufListing.Base(), 1, len, m_fListing );
+ m_dataListing = (const char *) m_bufListing.Base();
+ }
+ }
+ }
+}
+
+}; // namespace CmdSink