diff options
| author | Luke Street <luke.street@encounterpc.com> | 2023-09-10 00:42:26 -0400 |
|---|---|---|
| committer | Luke Street <luke.street@encounterpc.com> | 2023-09-10 00:48:55 -0400 |
| commit | adb95b135c3d7498eba29bbd9728d345eed5a407 (patch) | |
| tree | 655575b939c12067569263171b68c079b1a232c8 /src/JSystem/JSupport/JSUInputStream.cpp | |
| parent | 81ac53f1317dafb3506ae3ed8b2820d40645c3c8 (diff) | |
Import project
Original repository: https://github.com/encounter/ww
Diffstat (limited to 'src/JSystem/JSupport/JSUInputStream.cpp')
| -rw-r--r-- | src/JSystem/JSupport/JSUInputStream.cpp | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/src/JSystem/JSupport/JSUInputStream.cpp b/src/JSystem/JSupport/JSUInputStream.cpp new file mode 100644 index 00000000..188d1098 --- /dev/null +++ b/src/JSystem/JSupport/JSUInputStream.cpp @@ -0,0 +1,76 @@ +// +// Generated by dtk +// Translation Unit: JSUInputStream.cpp +// + +#include "JSystem/JSupport/JSUInputStream.h" +#include "JSystem/JSupport/JSURandomInputStream.h" + +/* 802BF3F4-802BF47C .text __dt__14JSUInputStreamFv */ +JSUInputStream::~JSUInputStream() { +} + +/* 802BF47C-802BF4D4 .text read__14JSUInputStreamFPvl */ +s32 JSUInputStream::read(void* buffer, s32 numBytes) { + s32 bytesRead = readData(buffer, numBytes); + if (bytesRead != numBytes) { + setState(IOS_STATE_1); + } + return bytesRead; +} + +/* 802BF4D4-802BF554 .text skip__14JSUInputStreamFl */ +s32 JSUInputStream::skip(s32 count) { + s32 skipCount = 0; + u8 buffer[1]; + while (count > skipCount) { + if (readData(&buffer, 1) != 1) { + setState(IOS_STATE_1); + break; + } + skipCount++; + } + return skipCount; +} + +/* 802BF554-802BF5E0 .text align__20JSURandomInputStreamFl */ +s32 JSURandomInputStream::align(s32 alignment) { + s32 currentPos = getPosition(); + s32 offset = (alignment + currentPos); + offset -= 1; + offset &= ~(alignment - 1); + s32 alignmentOffset = offset - currentPos; + if (alignmentOffset != 0) { + s32 seekLen = seekPos(offset, JSUStreamSeekFrom_SET); + if (seekLen != alignmentOffset) { + setState(IOS_STATE_1); + } + } + return alignmentOffset; +} + +/* 802BF5E0-802BF63C .text skip__20JSURandomInputStreamFl */ +s32 JSURandomInputStream::skip(s32 param_0) { + s32 val = seekPos(param_0, JSUStreamSeekFrom_CUR); + if (val != param_0) { + setState(IOS_STATE_1); + } + return val; +} + +/* 802BF63C-802BF6C0 .text peek__20JSURandomInputStreamFPvl */ +s32 JSURandomInputStream::peek(void* buffer, s32 numBytes) { + s32 oldPos = getPosition(); + s32 bytesRead = read(buffer, numBytes); + if (bytesRead != 0) { + seekPos(oldPos, JSUStreamSeekFrom_SET); + } + return bytesRead; +} + +/* 802BF6C0-802BF704 .text seek__20JSURandomInputStreamFl17JSUStreamSeekFrom */ +s32 JSURandomInputStream::seek(s32 param_0, JSUStreamSeekFrom param_1) { + s32 seekResult = seekPos(param_0, param_1); + clrState(IOS_STATE_1); + return seekResult; +} |
