diff options
| author | TakaRikka <38417346+TakaRikka@users.noreply.github.com> | 2025-01-19 21:05:53 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-01-19 22:05:53 -0700 |
| commit | e0824a15908f4e6ad70d3d0f2364efe043a98c0f (patch) | |
| tree | 3e85ea5ea5282c7ca3397a3adc1535674fc496aa /src/JSystem/JSupport/JSUInputStream.cpp | |
| parent | 7137f49bfc9535d95f980fb92552adf7b7c3c3ce (diff) | |
most of JHostIO / m_Do_hostIO done (#2288)
Diffstat (limited to 'src/JSystem/JSupport/JSUInputStream.cpp')
| -rw-r--r-- | src/JSystem/JSupport/JSUInputStream.cpp | 42 |
1 files changed, 32 insertions, 10 deletions
diff --git a/src/JSystem/JSupport/JSUInputStream.cpp b/src/JSystem/JSupport/JSUInputStream.cpp index 4e7cbd3fee..8197bdb192 100644 --- a/src/JSystem/JSupport/JSUInputStream.cpp +++ b/src/JSystem/JSupport/JSUInputStream.cpp @@ -5,6 +5,7 @@ #include "JSystem/JSupport/JSUInputStream.h" #include "JSystem/JSupport/JSURandomInputStream.h" +#include <dolphin.h> // // Forward References: @@ -38,7 +39,11 @@ extern void* __vt__20JSURandomInputStream[9] = { }; /* 802DC23C-802DC298 2D6B7C 005C+00 1/0 6/6 0/0 .text __dt__14JSUInputStreamFv */ -JSUInputStream::~JSUInputStream() {} +JSUInputStream::~JSUInputStream() { + if (!isGood()) { + OS_REPORT("JSUInputStream: occur error.\n"); + } +} /* 802DC298-802DC2F0 2D6BD8 0058+00 1/1 20/20 0/0 .text read__14JSUInputStreamFPvl */ s32 JSUInputStream::read(void* buffer, s32 numBytes) { @@ -49,29 +54,46 @@ s32 JSUInputStream::read(void* buffer, s32 numBytes) { return bytesRead; } +char* JSUInputStream::read(char* str) { + u16 sp8; + if (readData(&sp8, sizeof(sp8)) != sizeof(sp8)) { + *str = 0; + setState(IOS_STATE_1); + return 0; + } + + s32 len = readData(str, sp8); + str[len] = 0; + if (len != sp8) { + setState(IOS_STATE_1); + } + return str; +} + /* 802DC2F0-802DC370 2D6C30 0080+00 1/0 0/0 0/0 .text skip__14JSUInputStreamFl */ s32 JSUInputStream::skip(s32 count) { + u8 buffer; s32 skipCount = 0; - u8 buffer[1]; - while (count > skipCount) { - if (readData(&buffer, 1) != 1) { + for (; skipCount < count; skipCount++) { + if (readData(&buffer, sizeof(buffer)) != sizeof(buffer)) { setState(IOS_STATE_1); break; } - skipCount++; } + return skipCount; } /* 802DC370-802DC3FC 2D6CB0 008C+00 0/0 1/1 0/0 .text align__20JSURandomInputStreamFl */ s32 JSURandomInputStream::align(s32 alignment) { + s32 seekLen = 0; s32 currentPos = getPosition(); - s32 offset = (alignment + currentPos); - offset -= 1; - offset &= ~(alignment - 1); + + s32 offset = (alignment - 1 + currentPos) & ~(alignment - 1); s32 alignmentOffset = offset - currentPos; + if (alignmentOffset != 0) { - s32 seekLen = seekPos(offset, JSUStreamSeekFrom_SET); + seekLen = seekPos(offset, JSUStreamSeekFrom_SET); if (seekLen != alignmentOffset) { setState(IOS_STATE_1); } @@ -104,4 +126,4 @@ s32 JSURandomInputStream::seek(s32 param_0, JSUStreamSeekFrom param_1) { s32 seekResult = seekPos(param_0, param_1); clrState(IOS_STATE_1); return seekResult; -}
\ No newline at end of file +} |
