diff --git a/cube/swiss/source/cheats/cheats.c b/cube/swiss/source/cheats/cheats.c index 2f1e0b97..3d2e42f0 100644 --- a/cube/swiss/source/cheats/cheats.c +++ b/cube/swiss/source/cheats/cheats.c @@ -194,10 +194,9 @@ int findCheats(bool silent) { memset(trimmedGameId, 0, 8); memcpy(trimmedGameId, (char*)&GCMDisk, 6); file_handle *cheatsFile = memalign(32,sizeof(file_handle)); - memcpy(cheatsFile, devices[DEVICE_CUR]->initial, sizeof(file_handle)); + memset(cheatsFile, 0, sizeof(file_handle)); sprintf(cheatsFile->name, "%s/cheats/%s.txt", devices[DEVICE_CUR]->initial->name, trimmedGameId); print_gecko("Looking for cheats file @ %s\r\n", cheatsFile->name); - cheatsFile->size = -1; devices[DEVICE_TEMP] = devices[DEVICE_CUR]; @@ -206,20 +205,20 @@ int findCheats(bool silent) { // Try SD slots now devices[DEVICE_TEMP] = &__device_sd_a; file_handle *slotFile = devices[DEVICE_TEMP]->initial; - memcpy(cheatsFile, slotFile, sizeof(file_handle)); + memset(cheatsFile, 0, sizeof(file_handle)); sprintf(cheatsFile->name, "%s/cheats/%s.txt", slotFile->name, trimmedGameId); print_gecko("Looking for cheats file @ %s\r\n", cheatsFile->name); - cheatsFile->size = -1; + devices[DEVICE_TEMP]->init(cheatsFile); if(devices[DEVICE_TEMP]->readFile(cheatsFile, &trimmedGameId, 8) != 8) { devices[DEVICE_TEMP] = NULL; } devices[DEVICE_TEMP] = &__device_sd_b; slotFile = devices[DEVICE_TEMP]->initial; - memcpy(cheatsFile, slotFile, sizeof(file_handle)); + memset(cheatsFile, 0, sizeof(file_handle)); sprintf(cheatsFile->name, "%s/cheats/%s.txt", slotFile->name, trimmedGameId); print_gecko("Looking for cheats file @ %s\r\n", cheatsFile->name); - cheatsFile->size = -1; + devices[DEVICE_TEMP]->init(cheatsFile); if(devices[DEVICE_TEMP]->readFile(cheatsFile, &trimmedGameId, 8) != 8) { devices[DEVICE_TEMP] = NULL; diff --git a/cube/swiss/source/devices/fat/deviceHandler-FAT.c b/cube/swiss/source/devices/fat/deviceHandler-FAT.c index 372f547d..ad429e6f 100644 --- a/cube/swiss/source/devices/fat/deviceHandler-FAT.c +++ b/cube/swiss/source/devices/fat/deviceHandler-FAT.c @@ -161,7 +161,7 @@ s32 deviceHandler_FAT_seekFile(file_handle* file, u32 where, u32 type){ s32 deviceHandler_FAT_readFile(file_handle* file, void* buffer, u32 length){ if(!file->fp) { file->fp = fopen( file->name, "r+" ); - if(file->size == 0) { + if(file->size <= 0) { struct stat fstat; stat(file->name,&fstat); file->size = fstat.st_size; diff --git a/cube/swiss/source/devices/wiikeyfusion/deviceHandler-wiikeyfusion.c b/cube/swiss/source/devices/wiikeyfusion/deviceHandler-wiikeyfusion.c index 059c64e5..0d2a5bbc 100644 --- a/cube/swiss/source/devices/wiikeyfusion/deviceHandler-wiikeyfusion.c +++ b/cube/swiss/source/devices/wiikeyfusion/deviceHandler-wiikeyfusion.c @@ -108,7 +108,7 @@ s32 deviceHandler_WKF_seekFile(file_handle* file, u32 where, u32 type){ s32 deviceHandler_WKF_readFile(file_handle* file, void* buffer, u32 length){ if(!file->fp) { file->fp = fopen( file->name, "rb" ); - if(file->size == -1) { + if(file->size <= 0) { struct stat fstat; stat(file->name,&fstat); file->size = fstat.st_size;