finished updating memorypak
This commit is contained in:
parent
8fd9f90522
commit
3c2a57d057
@ -10,7 +10,6 @@
|
|||||||
#include "types.h"
|
#include "types.h"
|
||||||
#include "memorypak.h"
|
#include "memorypak.h"
|
||||||
#include "ff.h"
|
#include "ff.h"
|
||||||
#include "fat_old.h"
|
|
||||||
#include "menu.h"
|
#include "menu.h"
|
||||||
#include "mem.h"
|
#include "mem.h"
|
||||||
#include "strlib.h"
|
#include "strlib.h"
|
||||||
@ -391,44 +390,57 @@ void mpk_to_file(display_context_t disp, char *mpk_filename, int quick)
|
|||||||
else
|
else
|
||||||
sprintf(buff, "%s%s.MPK", mempak_path, mpk_filename);
|
sprintf(buff, "%s%s.MPK", mempak_path, mpk_filename);
|
||||||
|
|
||||||
FatRecord rec_tmpf;
|
FRESULT fr;
|
||||||
|
FILINFO fno;
|
||||||
|
|
||||||
if (!fatFindRecord(buff, &rec_tmpf, 0))
|
fr = f_stat(buff, &fno);
|
||||||
{ //filename already exists
|
if(fr == FR_OK)
|
||||||
|
{
|
||||||
printText("File exists", 9, -1, disp);
|
printText("File exists", 9, -1, disp);
|
||||||
if (quick)
|
if (quick)
|
||||||
printText("override", 9, -1, disp);
|
printText("override", 9, -1, disp);
|
||||||
else
|
else
|
||||||
while (ok == 0)
|
while (fr == FR_OK)
|
||||||
{
|
{
|
||||||
sprintf(buff, "%s%s%i.MPK", mempak_path, mpk_filename, v);
|
sprintf(buff, "%s%s%i.MPK", mempak_path, mpk_filename, v);
|
||||||
|
|
||||||
ok = fatFindRecord(buff, &rec_tmpf, 0);
|
fr = f_stat(buff, &fno);
|
||||||
if (ok == 0)
|
if (fr == FR_OK)
|
||||||
v++;
|
v++;
|
||||||
else
|
else
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
u8 resp = 0;
|
FRESULT result;
|
||||||
resp = fatCreateRecIfNotExist(buff, 0);
|
FIL file;
|
||||||
resp = fatOpenFileByName(buff, 32768 / 512);
|
result = f_open(&file, buff, FA_OPEN_ALWAYS);
|
||||||
|
|
||||||
controller_init();
|
if (result == FR_OK)
|
||||||
|
|
||||||
int err = 0;
|
|
||||||
for (int j = 0; j < 128; j++)
|
|
||||||
{
|
{
|
||||||
err |= read_mempak_sector(0, j, &mempak_data[j * 256]);
|
controller_init();
|
||||||
|
|
||||||
|
int err = 0;
|
||||||
|
for (int j = 0; j < 128; j++)
|
||||||
|
{
|
||||||
|
err |= read_mempak_sector(0, j, &mempak_data[j * 256]);
|
||||||
|
}
|
||||||
|
|
||||||
|
UINT* bw;
|
||||||
|
result =
|
||||||
|
f_write (
|
||||||
|
&file, /* [IN] Pointer to the file object structure */
|
||||||
|
&mempak_data, /* [IN] Pointer to the data to be written */
|
||||||
|
32768, /* [IN] Number of bytes to write */
|
||||||
|
bw /* [OUT] Pointer to the variable to return number of bytes written */
|
||||||
|
);
|
||||||
|
|
||||||
|
result = f_close(&file);
|
||||||
|
|
||||||
|
|
||||||
|
sprintf(buff, "File: %s%i.MPK", mpk_filename, v);
|
||||||
|
|
||||||
|
printText(buff, 9, -1, disp);
|
||||||
|
printText("backup done...", 9, -1, disp);
|
||||||
}
|
}
|
||||||
|
|
||||||
fatWriteFile(&mempak_data, 32768 / 512);
|
|
||||||
|
|
||||||
sleep(500);
|
|
||||||
|
|
||||||
sprintf(buff, "File: %s%i.MPK", mpk_filename, v);
|
|
||||||
|
|
||||||
printText(buff, 9, -1, disp);
|
|
||||||
printText("backup done...", 9, -1, disp);
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user