I would have to optimize this function, but I don't know whether to do...
I've increased the buffer and free it at the end, it works very good and fast, but (I think) the best buffer depends on the file size, right?
Code: Select all
int fileCopy(char* inSrc , char* inDest)
{
SceUID tempSrc = sceIoOpen(inSrc, PSP_O_RDONLY, 0777);
if(!tempSrc){
return -1; // Error while reading file...
}
SceUID tempDest = sceIoOpen(inDest, PSP_O_WRONLY | PSP_O_CREAT, 0777);
if(!tempDest) {
sceIoClose(tempSrc);
return -2; // Error while writing file...
}
char* tempData;
tempData=(char*)malloc(1024*1024);
int tempRead = sceIoRead(tempSrc, tempData, 1024*1024);
int tempWritten;
while(tempRead > 0){
tempWritten = sceIoWrite(tempDest, tempData, tempRead);
tempRead = sceIoRead(tempSrc, tempData, 1024*1024);
}
sceIoClose(tempDest);
sceIoClose(tempSrc);
free(tempData);
return 0;
}