| 32 | } |
| 33 | |
| 34 | s32 __CARDSetStatusExAsync(s32 chan, s32 fileNo, CARDDir* dirent, CARDCallback callback) |
| 35 | { |
| 36 | CARDControl* card; |
| 37 | CARDDir* dir; |
| 38 | CARDDir* ent; |
| 39 | s32 result; |
| 40 | u8* p; |
| 41 | s32 i; |
| 42 | |
| 43 | if ((fileNo < 0) || (fileNo >= CARD_MAX_FILE) || ((u8)dirent->fileName[0] == 0xFF) || |
| 44 | ((u8)dirent->fileName[0] == 0)) |
| 45 | { |
| 46 | return CARD_RESULT_FATAL_ERROR; |
| 47 | } |
| 48 | |
| 49 | result = __CARDGetControlBlock(chan, &card); |
| 50 | if (result < 0) |
| 51 | { |
| 52 | return result; |
| 53 | } |
| 54 | |
| 55 | dir = __CARDGetDirBlock(card); |
| 56 | ent = &dir[fileNo]; |
| 57 | result = __CARDIsWritable(card, ent); |
| 58 | if (result < 0) |
| 59 | { |
| 60 | return __CARDPutControlBlock(card, result); |
| 61 | } |
| 62 | |
| 63 | for (p = dirent->fileName; p < (u8*)&dirent->time; p++) |
| 64 | { |
| 65 | if (*p != 0) |
| 66 | { |
| 67 | continue; |
| 68 | } |
| 69 | while ((++p) < (u8*)&dirent->time) |
| 70 | { |
| 71 | *p = 0; |
| 72 | } |
| 73 | break; |
| 74 | } |
| 75 | |
| 76 | if (dirent->permission & 0x20) |
| 77 | { |
| 78 | memset(dirent->gameName, 0, sizeof(dirent->gameName)); |
| 79 | memset(dirent->company, 0, sizeof(dirent->company)); |
| 80 | } |
| 81 | |
| 82 | if (dirent->permission & 0x40) |
| 83 | { |
| 84 | memset(dirent->gameName, 0, sizeof(dirent->gameName)); |
| 85 | } |
| 86 | |
| 87 | if ((memcmp(&ent->fileName, &dirent->fileName, 32) != 0) || |
| 88 | (memcmp(ent->gameName, dirent->gameName, 4) != 0) || |
| 89 | (memcmp(ent->company, dirent->company, 2) != 0)) |
| 90 | { |
| 91 | for (i = 0; i < CARD_MAX_FILE; i++) |
no test coverage detected