the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
at main 52 lines 1.5 kB view raw
1#include "stdafx.h" 2 3#include "InputStream.h" 4#include "DataInputStream.h" 5#include "InputStreamReader.h" 6 7//Creates an InputStreamReader that uses the default charset. 8//Parameters: 9//in - An InputStream 10InputStreamReader::InputStreamReader(InputStream *in) : stream( new DataInputStream( in ) ) 11{ 12} 13 14//Closes the stream and releases any system resources associated with it. 15//Once the stream has been closed, further read(), ready(), mark(), reset(), or skip() invocations will throw an IOException. 16//Closing a previously closed stream has no effect. 17void InputStreamReader::close() 18{ 19 stream->close(); 20} 21 22//Reads a single character. 23//Returns: 24//The character read, or -1 if the end of the stream has been reached 25int InputStreamReader::read() 26{ 27 return stream->readUTFChar(); 28} 29 30//Reads characters into a portion of an array. 31//Parameters: 32//cbuf - Destination buffer 33//offset - Offset at which to start storing characters 34//length - Maximum number of characters to read 35//Returns: 36//The number of characters read, or -1 if the end of the stream has been reached 37int InputStreamReader::read(wchar_t cbuf[], unsigned int offset, unsigned int length) 38{ 39 unsigned int charsRead = 0; 40 for( unsigned int i = offset; i < offset + length; i++ ) 41 { 42 wchar_t value = (wchar_t)stream->readUTFChar(); 43 if( value != -1 ) 44 { 45 cbuf[i] = value; 46 charsRead++; 47 } 48 // TODO 4J Stu - The read might throw an exception? In which case we should return -1 49 else break; 50 } 51 return charsRead; 52}