Following up my last post here about copying an entire folder, I started to write my functions to do the job.
It compiles fine, but when I run it on the PSP, it freezes and shut down.
I'm trying to do a basic copy txt file and paste. The idea is to copy all the file contents and create a new text file with the contents.
It's very strange, 'cause basically it's kind of creating the files, but is corrupting the whole thing. And also, it is creating it as a binary. Is there any way to do it in a normal way, like "cloning" the file, and without corrupting it?
Here's my code. Is thre anything wrong there?
Code: Select all
void copy(){
char write_buffer[128*1024];
//Opens the file
int target=sceIoOpen("ms0:/test.txt", PSP_O_WRONLY, 0777);
int newFile=sceIoOpen("ms0:/test1.txt", PSP_O_APPEND|PSP_O_CREAT, 0777);
//Creates a buffer for the file contents
char* data;
//Reads the contents
sceIoRead(target, &data, sizeof(data));
sprintf(write_buffer, data);
sceIoWrite(newFile, write_buffer, sizeof(write_buffer));
sceIoClose(target);
sceIoClose(newFile);
}