diff options
| author | daoge_cmd <3523206925@qq.com> | 2026-03-01 12:16:08 +0800 |
|---|---|---|
| committer | daoge_cmd <3523206925@qq.com> | 2026-03-01 12:16:08 +0800 |
| commit | b691c43c44ff180d10e7d4a9afc83b98551ff586 (patch) | |
| tree | 3e9849222cbc6ba49f2f1fc6e5fe7179632c7390 /Minecraft.World/InputStreamReader.cpp | |
| parent | def8cb415354ac390b7e89052a50605285f1aca9 (diff) | |
Initial commit
Diffstat (limited to 'Minecraft.World/InputStreamReader.cpp')
| -rw-r--r-- | Minecraft.World/InputStreamReader.cpp | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/Minecraft.World/InputStreamReader.cpp b/Minecraft.World/InputStreamReader.cpp new file mode 100644 index 00000000..4a565cf4 --- /dev/null +++ b/Minecraft.World/InputStreamReader.cpp @@ -0,0 +1,52 @@ +#include "stdafx.h" + +#include "InputStream.h" +#include "DataInputStream.h" +#include "InputStreamReader.h" + +//Creates an InputStreamReader that uses the default charset. +//Parameters: +//in - An InputStream +InputStreamReader::InputStreamReader(InputStream *in) : stream( new DataInputStream( in ) ) +{ +} + +//Closes the stream and releases any system resources associated with it. +//Once the stream has been closed, further read(), ready(), mark(), reset(), or skip() invocations will throw an IOException. +//Closing a previously closed stream has no effect. +void InputStreamReader::close() +{ + stream->close(); +} + +//Reads a single character. +//Returns: +//The character read, or -1 if the end of the stream has been reached +int InputStreamReader::read() +{ + return stream->readUTFChar(); +} + +//Reads characters into a portion of an array. +//Parameters: +//cbuf - Destination buffer +//offset - Offset at which to start storing characters +//length - Maximum number of characters to read +//Returns: +//The number of characters read, or -1 if the end of the stream has been reached +int InputStreamReader::read(wchar_t cbuf[], unsigned int offset, unsigned int length) +{ + unsigned int charsRead = 0; + for( unsigned int i = offset; i < offset + length; i++ ) + { + wchar_t value = (wchar_t)stream->readUTFChar(); + if( value != -1 ) + { + cbuf[i] = value; + charsRead++; + } + // TODO 4J Stu - The read might throw an exception? In which case we should return -1 + else break; + } + return charsRead; +}
\ No newline at end of file |
