Hello,
I wish I save the scores in a file on the SD card , as simply as possible ... the save file is created but it does 1ko and contains nothing ...
I wish I save the scores in a file on the SD card , as simply as possible ... the save file is created but it does 1ko and contains nothing ...
Code:
//A sauvergarder
bool niveau_unlocked[MAX_LVL];
bool niveau_solved[MAX_LVL];
u8 niveau_best[MAX_LVL];
//End save
void sauvegarder()
{
fsInit();
u32 bytesWrite;
Handle fileHandle;
char filename[15] = "/TILES_2DS.SAV";
//setup SDMC archive
FS_archive sdmcArchive = (FS_archive){ARCH_SDMC, (FS_path){PATH_EMPTY, 1, (u8*)""}};
//create file path struct
FS_path filePath = FS_makePath(PATH_CHAR, filename);
//create file
FSUSER_OpenFileDirectly(NULL, &fileHandle, sdmcArchive, filePath, FS_OPEN_READ|FS_OPEN_WRITE|FS_OPEN_CREATE, FS_ATTRIBUTE_NONE);
//Write file
for (i = 0; i < MAX_LVL; i++)
{
FSFILE_Write(fileHandle, &bytesWrite, 0x0, &niveau_unlocked[i], sizeof(niveau_unlocked[i]), FS_WRITE_FLUSH);
FSFILE_Write(fileHandle, &bytesWrite, 0x0, &niveau_solved[i], sizeof(niveau_solved[i]), FS_WRITE_FLUSH);
FSFILE_Write(fileHandle, &bytesWrite, 0x0, &niveau_best[i], sizeof(niveau_best[i]), FS_WRITE_FLUSH);
}
//Close file
FSFILE_Close(fileHandle);
svcCloseHandle(fileHandle);
}