MCPcopy Create free account
hub / github.com/cemu-project/Cemu / __FSWriteFileWithPosAsync

Function __FSWriteFileWithPosAsync

src/Cafe/OS/libs/coreinit/coreinit_FS.cpp:1154–1183  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1152 }
1153
1154 sint32 __FSWriteFileWithPosAsync(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, void* dest, uint32 size, uint32 count, bool useFilePos, uint32 filePos, uint32 fileHandle, uint32 flag, uint32 errorMask, FSAsyncParams* fsAsyncParams)
1155 {
1156 _FSCmdIntro();
1157 if (size == 0 || count == 0 || dest == nullptr)
1158 dest = _tempFSSpace.GetPtr();
1159 sint64 transferSizeS64 = (sint64)size * (sint64)count;
1160 if (transferSizeS64 < 0 || (transferSizeS64 >= 2LL * 1024LL * 1024LL * 1024LL))
1161 {
1162 // size below 0 or over 2GB
1163 cemu_assert(false);
1164 return -0x400;
1165 }
1166
1167 // coreinit.rpl splits up each write into smaller chunks (probably to support canceling big writes). This is handled by a specific
1168 // callback for the __FSQueueCmd functions. Whenever a chunk is written, it's getting re-queued until the writing has been completed.
1169 // For this it writes values into the fsCmdBlockBody->returnValues struct. At the moment we go the lazy route of just writing everything
1170 // at once, so we can skip the initialization of these values.
1171
1172 if (useFilePos)
1173 flag |= FSA_CMD_FLAG_SET_POS;
1174 else
1175 flag &= ~FSA_CMD_FLAG_SET_POS;
1176
1177 FSA_RESULT prepareResult = __FSPrepareCmd_WriteFile(&fsCmdBlockBody->fsaShimBuffer, fsClientBody->iosuFSAHandle, dest, size, count, filePos, fileHandle, flag);
1178 if (prepareResult != FSA_RESULT::OK)
1179 return (FSStatus)_FSAStatusToFSStatus(prepareResult);
1180
1181 __FSQueueCmd(&fsClientBody->fsCmdQueue, fsCmdBlockBody, RPLLoader_MakePPCCallable(export___FSQueueDefaultFinishFunc));
1182 return (FSStatus)FS_RESULT::SUCCESS;
1183 }
1184
1185 sint32 FSWriteFileAsync(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, void* src, uint32 size, uint32 count, uint32 fileHandle, uint32 flag, uint32 errorMask, FSAsyncParams* fsAsyncParams)
1186 {

Callers 2

FSWriteFileAsyncFunction · 0.85
FSWriteFileWithPosAsyncFunction · 0.85

Calls 6

cemu_assertFunction · 0.85
__FSPrepareCmd_WriteFileFunction · 0.85
_FSAStatusToFSStatusFunction · 0.85
__FSQueueCmdFunction · 0.85
GetPtrMethod · 0.45

Tested by

no test coverage detected