MCPcopy Create free account
hub / github.com/bfbbdecomp/bfbb / CARDReadAsync

Function CARDReadAsync

src/dolphin/src/card/CARDRead.c:104–139  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

102}
103
104s32 CARDReadAsync(CARDFileInfo* fileInfo, void* buf, s32 length, s32 offset,
105 CARDCallback callback) {
106 CARDControl* card;
107 s32 result;
108 CARDDir* dir;
109 CARDDir* ent;
110
111 if (OFFSET(offset, CARD_SEG_SIZE) != 0 || OFFSET(length, CARD_SEG_SIZE) != 0) {
112 return CARD_RESULT_FATAL_ERROR;
113 }
114 result = __CARDSeek(fileInfo, length, offset, &card);
115 if (result < 0) {
116 return result;
117 }
118
119 dir = __CARDGetDirBlock(card);
120 ent = &dir[fileInfo->fileNo];
121 result = __CARDIsReadable(card, ent);
122
123 if (result < 0)
124 {
125 return __CARDPutControlBlock(card, result);
126 }
127
128 DCInvalidateRange(buf, (u32)length);
129 card->apiCallback = callback ? callback : __CARDDefaultApiCallback;
130
131 offset = (s32)OFFSET(fileInfo->offset, card->sectorSize);
132 length = (length < card->sectorSize - offset) ? length : card->sectorSize - offset;
133 result = __CARDRead(fileInfo->chan, card->sectorSize * (u32)fileInfo->iBlock + offset, length,
134 buf, ReadCallback);
135 if (result < 0) {
136 __CARDPutControlBlock(card, result);
137 }
138 return result;
139}
140
141s32 CARDRead(CARDFileInfo *fileInfo, void *buffer, s32 length, s32 offset)
142{

Callers 2

CARDReadFunction · 0.85
iSG_mcqa_freadFunction · 0.85

Calls 5

__CARDSeekFunction · 0.85
__CARDGetDirBlockFunction · 0.85
__CARDIsReadableFunction · 0.85
__CARDPutControlBlockFunction · 0.85
__CARDReadFunction · 0.85

Tested by

no test coverage detected