 |
forums.ps2dev.org Homebrew PS2, PSP & PS3 Development Discussions
|
| View previous topic :: View next topic |
| Author |
Message |
ne0h
Joined: 21 Feb 2008 Posts: 386
|
Posted: Tue Jun 03, 2008 6:47 am Post subject: Optimizing a copy funct |
|
|
Hi,
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: |
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;
}
|
Can anyone give me a little help? _________________ Get Xplora! |
|
| Back to top |
|
 |
cyberfish
Joined: 19 May 2008 Posts: 19
|
Posted: Tue Jun 03, 2008 5:44 pm Post subject: |
|
|
I don't think it would really be dependent on the file size.
Try several buffer sizes and benchmark them =).
*edit*
BTW, why is everything named temp?... The function has its own scope that is isolated from the global namespace, so you don't need to try to protect the global namespace. |
|
| Back to top |
|
 |
ne0h
Joined: 21 Feb 2008 Posts: 386
|
Posted: Wed Jun 04, 2008 12:00 am Post subject: |
|
|
ok, I've resolved! _________________ Get Xplora! |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|