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

Function CARDWriteAsync

src/dolphin/src/card/CARDWrite.c:91–128  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

89}
90
91s32 CARDWriteAsync(CARDFileInfo* fileInfo, const void* buf, s32 length, s32 offset,
92 CARDCallback callback)
93{
94 CARDControl* card;
95 s32 result;
96 CARDDir* dir;
97 CARDDir* ent;
98
99 result = __CARDSeek(fileInfo, length, offset, &card);
100 if (result < 0)
101 {
102 return result;
103 }
104
105 if (OFFSET(offset, card->sectorSize) != 0 || OFFSET(length, card->sectorSize) != 0)
106 {
107 return __CARDPutControlBlock(card, CARD_RESULT_FATAL_ERROR);
108 }
109
110 dir = __CARDGetDirBlock(card);
111 ent = &dir[fileInfo->fileNo];
112 result = __CARDIsWritable(card, ent);
113 if (result < 0)
114 {
115 return __CARDPutControlBlock(card, result);
116 }
117
118 DCStoreRange((void*)buf, (u32)length);
119 card->apiCallback = callback ? callback : __CARDDefaultApiCallback;
120 card->buffer = (void*)buf;
121 result =
122 __CARDEraseSector(fileInfo->chan, card->sectorSize * (u32)fileInfo->iBlock, EraseCallback);
123 if (result < 0)
124 {
125 __CARDPutControlBlock(card, result);
126 }
127 return result;
128}

Callers 1

iSG_mcqa_fwriteFunction · 0.85

Calls 5

__CARDSeekFunction · 0.85
__CARDPutControlBlockFunction · 0.85
__CARDGetDirBlockFunction · 0.85
__CARDIsWritableFunction · 0.85
__CARDEraseSectorFunction · 0.85

Tested by

no test coverage detected