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

Function VerifyDir

src/dolphin/src/card/CARDCheck.c:80–129  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

78}
79
80static s32 VerifyDir(CARDControl* card, int* outCurrent)
81{
82 CARDDir* dir[2];
83 CARDDirCheck* check[2];
84 u16 checkSum;
85 u16 checkSumInv;
86 int i;
87 int errors;
88 int current;
89
90 current = errors = 0;
91 for (i = 0; i < 2; i++)
92 {
93 dir[i] = (CARDDir*)((u8*)card->workArea + (1 + i) * CARD_SYSTEM_BLOCK_SIZE);
94 check[i] = __CARDGetDirCheck(dir[i]);
95 __CARDCheckSum(dir[i], CARD_SYSTEM_BLOCK_SIZE - sizeof(u32), &checkSum, &checkSumInv);
96 if (check[i]->checkSum != checkSum || check[i]->checkSumInv != checkSumInv)
97 {
98 ++errors;
99 current = i;
100 card->currentDir = 0;
101 }
102 }
103
104 if (0 == errors)
105 {
106 if (card->currentDir == 0)
107 {
108 if ((check[0]->checkCode - check[1]->checkCode) < 0)
109 {
110 current = 0;
111 }
112 else
113 {
114 current = 1;
115 }
116 card->currentDir = dir[current];
117 memcpy(dir[current], dir[current ^ 1], CARD_SYSTEM_BLOCK_SIZE);
118 }
119 else
120 {
121 current = (card->currentDir == dir[0]) ? 0 : 1;
122 }
123 }
124 if (outCurrent)
125 {
126 *outCurrent = current;
127 }
128 return errors;
129}
130
131static s32 VerifyFAT(CARDControl* card, int* outCurrent)
132{

Callers 2

__CARDVerifyFunction · 0.85
CARDCheckExAsyncFunction · 0.85

Calls 2

__CARDCheckSumFunction · 0.85
memcpyFunction · 0.85

Tested by

no test coverage detected