| 102 | } |
| 103 | |
| 104 | s32 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 | |
| 141 | s32 CARDRead(CARDFileInfo *fileInfo, void *buffer, s32 length, s32 offset) |
| 142 | { |
no test coverage detected