summaryrefslogtreecommitdiff
path: root/src/JSystem/JSupport/JSUInputStream.cpp
blob: 4328449879da98f2b3443bd471b00d2546c33faf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
//
// Generated by dtk
// Translation Unit: JSUInputStream.cpp
//

#include "JSystem/JSystem.h" // IWYU pragma: keep

#include "JSystem/JSupport/JSUInputStream.h"
#include "JSystem/JSupport/JSURandomInputStream.h"
#include "dolphin/os/OS.h"

/* 802BF3F4-802BF47C       .text __dt__14JSUInputStreamFv */
JSUInputStream::~JSUInputStream() {
    if (!isGood())
        OSReport("JSUInputStream: occur error.\n");
}

/* 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;
}