Problem was that it was slow on my Sony MS because it uses the POSIX io functions (fopen, fclose etc). To speed up writing I need to convert the data to 64bit aligned (easily done), and port to sceIo functions which is what i'm having trouble with.
I have three main options:
1. Port all the code in file.cpp to use sceIo functions.
This was the first thing I tried to do, however it proved unsuccessful for some reason. Most of the functions were ported fine from fopen - sceIoOpen, except functions such as fflush and ferror which I either commented out or forced a succeed value.
The functions I couldn't find for sceIo were: fflush ferror clearerr and fileno; might these be important? The other function was ftell, which I substituted as: sceIoLseek((SceUID)hFile,0,SEEK_CUR);
This code ends up making the app throw a memory exception, which is odd, as I don't see where I can be losing memory from.
2. Try to port just the write code by closing the FILE and opening a SceUID, writing, closing then re-opening as FILE. My code ended up looking like this:
Code: Select all
u8* data2;data2=(u8*)memalign(64,Size);
memcpy(data2,Data,Size);
long told;
told = ftell(hFile);
fclose(hFile);
SceUID tempHFILE;
tempHFILE = sceIoOpen(hFileName,O_RDWR | O_CREAT, 0777);
//int Written=fwrite(data2,1,Size,hFile);
sceIoLseek(tempHFILE,told,SEEK_SET);
int Written=sceIoWrite(tempHFILE,data2,Size);
sceIoClose(tempHFILE);
hFile = fopen(hFileName,"rwb");
fseek(hFile,told+Written,SEEK_SET);
free(data2);
Success=Written==Size;// && !ferror(hFile);
3. Some sort of way to write the file using fwrite to memory, then using sceIoWrite to write to the stick.
Can anyone help with any of these?
Thanks.