rendered paste bodyint RestoreIdStorageKeys(char folderpath[70], char successpath[70], char errorpath[70])
{
char a[50];
char b[33];
char buffer[512];
char leaf[512];
int r = 0;
int f;
u16 key;
if (sceIdStorageIsReadOnly()) return -1;
sceKernelDelayThread(4*1000*1000);
for(key=0x0001;key<=0x9999;key++)
{
int x = sceIdStorageReadLeaf(key, buffer);
if (x == 0) {
sprintf(a, "%s0x%04X.bin", folderpath, key);
f = sceIoOpen(a, PSP_O_RDONLY, 0777);
if(f < 0)
{
sprintf(b, "Could not find: 0x%04X.bin", key);
int y = sceIoOpen(errorpath, PSP_O_WRONLY | PSP_O_CREAT, 0777);
sceIoWrite(y, b, 32);
sceIoClose(y);
r--;
}
else {
sceIoRead(f, leaf, 512);
sceIdStorageWriteLeaf(key, leaf);
sprintf(a, "Success key 0x%04X.bin", key);
int z = sceIoOpen(successpath, PSP_O_WRONLY | PSP_O_CREAT, 0777);
sceIoWrite(z, a, 34);
sceKernelDelayThread(2000 * 2000);
sceIoClose(z);
sceIoClose(f);
}
}
else if (x < 0)
{
sprintf(a, "%s0x%04X.bin", folderpath, key);
f = sceIoOpen(a, PSP_O_RDONLY, 0777);
if (f < 0) sceIoClose(f);
else {
sceIoRead(f, leaf, 512);
sceIdStorageCreateLeaf(key);
sceIdStorageWriteLeaf(key, leaf);
sprintf(a, "Successfully created and wrote 0x%04X.bin\n", key);
int z = sceIoOpen(successpath, PSP_O_WRONLY | PSP_O_CREAT, 0777);
sceIoWrite(z, a, 40);
sceIoClose(f);
sceIoClose(z);
}
}
}
return r;
}