yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
f65d756bf
master
1#include "output-stream.h" 2 3#include "../util/record-utility.h" 4 5namespace SlangRecord 6{ 7FileOutputStream ::FileOutputStream (const Slang ::String & fileName ,bool append ) 8{ 9Slang ::FileMode fileMode = append ?Slang ::FileMode ::Append :Slang ::FileMode ::Create ; 10Slang ::FileAccess fileAccess = Slang ::FileAccess ::Write ; 11Slang ::FileShare fileShare = Slang ::FileShare ::None ; 12 13SlangResult res = m_fileStream .init (fileName ,fileMode ,fileAccess ,fileShare ); 14 15if (res != SLANG_OK ) 16 { 17SlangRecord ::slangRecordLog ( 18SlangRecord ::LogLevel ::Error , 19"Failed to open file %s\n" , 20fileName .getBuffer ()); 21 std::abort (); 22 } 23} 24 25FileOutputStream ::~FileOutputStream () 26{ 27m_fileStream .close (); 28} 29 30void FileOutputStream ::write (const void * data ,size_t len ) 31{ 32SLANG_RECORD_CHECK (m_fileStream .write (data ,len )); 33} 34 35MemoryStream ::MemoryStream () 36 :m_memoryStream (Slang ::FileAccess ::Write ) 37{ 38} 39 40void FileOutputStream ::flush () 41{ 42SLANG_RECORD_CHECK (m_fileStream .flush ()); 43} 44 45void MemoryStream ::write (const void * data ,size_t len ) 46{ 47SLANG_RECORD_CHECK (m_memoryStream .write (data ,len )); 48} 49 50void MemoryStream ::flush () 51{ 52// This call will reset the underlying buffer to size 0, 53// and reset the write position to 0. 54m_memoryStream .setContent (nullptr ,0 ); 55} 56}// namespace SlangRecord