match JSupport

This commit is contained in:
SwareJonge
2025-06-17 00:00:16 +02:00
parent 0ab7bf6cd9
commit 37e7b7bf74
9 changed files with 212 additions and 14 deletions
+2 -2
View File
@@ -657,9 +657,9 @@ config.libs = [
JSystemLib(
"JSupport",
[
Object(NonMatching, "JSystem/JSupport/JSUFileStream.cpp"),
Object(Matching, "JSystem/JSupport/JSUFileStream.cpp"),
Object(Matching, "JSystem/JSupport/JSUInputStream.cpp"),
Object(NonMatching, "JSystem/JSupport/JSUList.cpp"),
Object(Matching, "JSystem/JSupport/JSUList.cpp"),
],
),
JSystemLib(
+6 -6
View File
@@ -130,17 +130,17 @@ public:
JKRArchive(s32, EMountMode);
virtual ~JKRArchive(); // _08
virtual bool becomeCurrent(const char*); // _10
virtual bool becomeCurrent(const char*); // _10
virtual void* getResource(const char* path); // _14
virtual void* getResource(u32 type, const char* name); // _18
virtual size_t readResource(void* resourceBuffer, u32 bufferSize, const char* path, JKRExpandSwitch expandSwitch); // _1C
virtual size_t readResource(void* resourceBuffer, u32 bufferSize, u32 type, const char* name); // _20
virtual void removeResourceAll(); // _24
virtual bool removeResource(void*); // _28
virtual bool detachResource(void*); // _2C
virtual s32 getResSize(const void*) const; // _30
virtual u32 countFile(const char*) const; // _34
virtual JKRFileFinder* getFirstFile(const char*) const; // _38
virtual bool removeResource(void*); // _28
virtual bool detachResource(void*); // _2C
virtual s32 getResSize(const void*) const; // _30
virtual u32 countFile(const char*) const; // _34
virtual JKRFileFinder* getFirstFile(const char*) const; // _38
virtual void* fetchResource(SDIFileEntry* entry, u32* outSize) = 0; // _40
virtual void* fetchResource(void* resourceBuffer, u32 bufferSize, SDIFileEntry* entry, u32* resSize, JKRExpandSwitch expandSwitch) = 0; // _44
-1
View File
@@ -56,7 +56,6 @@ protected:
const char* mVolumeName; // 0x28
u32 mVolumeType; // 0x2C
bool mIsMounted; // 0x30
u8 field_0x31[3]; // 0x31
u32 mMountCount; // 0x34
};
@@ -23,6 +23,12 @@ protected:
const void* mObject;
s32 mPosition;
};
class JSUFileOutputStream : public JSURandomOutputStream {
public:
JSUFileOutputStream(JKRFile *);
};
#endif
#endif
@@ -107,6 +107,15 @@ public:
return *this;
}
};
class JSUOutputStream : protected JSUIosBase {
public:
virtual ~JSUOutputStream();
virtual int getAvailable() const = 0;
virtual int skip(s32 amount);
virtual int readData(void* buf, s32 size) = 0;
};
#endif
#endif
@@ -21,6 +21,23 @@ public:
int peek(void* buf, s32 len);
int seek(s32 offset, JSUStreamSeekFrom from);
};
class JSURandomOutputStream : public JSUOutputStream {
public:
virtual ~JSURandomOutputStream() { }
virtual int getAvailable() const;
virtual int skip(s32 amount);
virtual int readData(void* buf, s32 count) = 0;
virtual int getLength() const = 0;
virtual int getPosition() const = 0;
virtual int seekPos(s32 offset, JSUStreamSeekFrom from) = 0;
int align(s32 alignment);
int peek(void* buf, s32 len);
int seek(s32 offset, JSUStreamSeekFrom from);
};
#endif
#endif
+2 -5
View File
@@ -18,9 +18,8 @@ JKRArchive* JKRArchive::check_mount_already(s32 entryNum, JKRHeap* pHeap) {
heap = JKRGetCurrentHeap();
}
JSUList<JKRFileLoader>& volumeList = JKRArchive::sVolumeList;
JSUListIterator<JKRFileLoader> iterator;
for (iterator = volumeList.getFirst(); iterator != volumeList.getEnd();
for (iterator = sVolumeList.getFirst(); iterator != sVolumeList.getEnd();
++iterator) {
if (iterator->getVolumeType() == 'RARC') {
JKRArchive* archive =
@@ -36,9 +35,7 @@ JKRArchive* JKRArchive::check_mount_already(s32 entryNum, JKRHeap* pHeap) {
}
JKRArchive* JKRArchive::check_mount_already(s32 entryNum) {
JSUList<JKRFileLoader>& volumeList = JKRArchive::sVolumeList;
JSUListIterator<JKRFileLoader> iterator;
for (iterator = volumeList.getFirst(); iterator != volumeList.getEnd();
for (JSUListIterator<JKRFileLoader> iterator = sVolumeList.getFirst(); iterator != sVolumeList.getEnd();
++iterator) {
if (iterator->getVolumeType() == 'RARC') {
JKRArchive* archive =
@@ -49,3 +49,7 @@ int JSUFileInputStream::seekPos(s32 offset, JSUStreamSeekFrom from) {
return this->mPosition - pos;
}
JSUFileOutputStream::JSUFileOutputStream(JKRFile *file) {
}
+166
View File
@@ -0,0 +1,166 @@
#include "JSystem/JSupport/JSUList.h"
JSUPtrLink::JSUPtrLink(void *pData) {
mPtrList = 0;
mData = pData;
mPrev = 0;
mNext = 0;
}
JSUPtrLink::~JSUPtrLink() {
if (mPtrList) {
mPtrList->remove(this);
}
}
JSUPtrList::JSUPtrList(bool doInitialize) {
if (doInitialize) {
initiate();
}
}
JSUPtrList::~JSUPtrList() {
JSUPtrLink* curHead = mHead;
for (int i = 0; i < mLinkCount; i++) {
curHead->mPtrList = 0;
curHead = curHead->mNext;
}
}
void JSUPtrList::initiate() {
mHead = 0;
mTail = 0;
mLinkCount = 0;
}
void JSUPtrList::setFirst(JSUPtrLink *pLink) {
pLink->mPtrList = this;
pLink->mPrev = 0;
pLink->mNext = 0;
mTail = pLink;
mHead = pLink;
mLinkCount = 1;
}
bool JSUPtrList::append(JSUPtrLink *pLink) {
bool validity = (pLink->mPtrList == 0);
if (!validity) {
validity = pLink->mPtrList->remove(pLink);
}
if (validity) {
if (!mLinkCount) {
setFirst(pLink);
}
else {
pLink->mPtrList = this;
pLink->mPrev = mTail;
pLink->mNext = 0;
mTail->mNext = pLink;
mTail = pLink;
mLinkCount = mLinkCount + 1;
}
}
return validity;
}
bool JSUPtrList::prepend(JSUPtrLink *pLink) {
bool validity = (pLink->mPtrList == 0);
if (!validity) {
validity = pLink->mPtrList->remove(pLink);
}
if (validity) {
if (!mLinkCount) {
setFirst(pLink);
}
else {
pLink->mPtrList = this;
pLink->mPrev = 0;
pLink->mNext = mHead;
mHead->mPrev = pLink;
mHead = pLink;
mLinkCount = mLinkCount + 1;
}
}
return validity;
}
bool JSUPtrList::insert(JSUPtrLink *pLink_1, JSUPtrLink *pLink_2) {
if (pLink_1 == mHead) {
return prepend(pLink_2);
}
if (!pLink_1) {
return append(pLink_2);
}
if (pLink_1->mPtrList != this) {
return false;
}
JSUPtrList* link2PtrList = pLink_2->mPtrList;
bool validity = (link2PtrList == 0);
if (!validity) {
validity = link2PtrList->remove(pLink_2);
}
if (validity) {
JSUPtrLink* prev = pLink_1->mPrev;
pLink_2->mPtrList = this;
pLink_2->mPrev = prev;
pLink_2->mNext = pLink_1;
prev->mNext = pLink_2;
pLink_1->mPrev = pLink_2;
mLinkCount++;
}
return validity;
}
bool JSUPtrList::remove(JSUPtrLink *pLink) {
bool isSameList = (pLink->mPtrList == this);
if (isSameList) {
if (mLinkCount == 1) {
mHead = 0;
mTail = 0;
}
else if (pLink == mHead) {
pLink->mNext->mPrev = 0;
mHead = pLink->mNext;
}
else if (pLink == mTail) {
pLink->mPrev->mNext = 0;
mTail = pLink->mPrev;
}
else {
pLink->mPrev->mNext = pLink->mNext;
pLink->mNext->mPrev = pLink->mPrev;
}
pLink->mPtrList = 0;
mLinkCount--;
}
return isSameList;
}
JSUPtrLink *JSUPtrList::getNthLink(u32 n) const
{
if (n >= mLinkCount)
{
return nullptr;
}
JSUPtrLink *curHead = mHead;
for (int i = 0; i < n; i++)
{
curHead = curHead->mNext;
}
return curHead;
}