Hi
Can somebody help me to COPY (not replace) a file from ms0 to another place on ms0?
And also how to create a directory (if dircetory not exsits)
Thanks !
Help to copy file
*gets out C book*
Well making a directory you can do, mkdir(dir, 0777);
And copying do (minus any sort of error handling):
Really you should learn basic C libraries first :)
Well making a directory you can do, mkdir(dir, 0777);
And copying do (minus any sort of error handling):
Code: Select all
FILE* in; FILE *out;
char buf[1024];
size_t len;
in = fopen(in, "rb");
out = fopen(out, "wb");
len = fread(buf, 1, 1024, in);
while(len > 0) {
fwrite(buf, 1, len, out);
len = fread(buf, 1, 1024, in);
}
fclose(in); fclose(out);
-
- Posts: 88
- Joined: Fri Aug 24, 2007 8:23 pm
Can i also use this :
and to copy then :
Example
EDIT : Yes i've tested it and it works!
Code: Select all
int fileCopy(char* inSrc, char* inDest) {
SceUID tempSrc = sceIoOpen(inSrc, PSP_O_RDONLY, 0777);
if(!tempSrc)
return -1;
SceUID tempDest = sceIoOpen(inDest, PSP_O_WRONLY | PSP_O_CREAT, 0777);
if(!tempDest) {
sceIoClose(tempSrc);
return -2;
}
char tempData[1024];
int tempRead = sceIoRead(tempSrc, tempData, 1024);
int tempWritten;
while(tempRead > 0) {
tempWritten = sceIoWrite(tempDest, tempData, tempRead);
if(tempWritten != tempRead) {
sceIoClose(tempDest);
sceIoClose(tempSrc);
sceIoRemove(inDest);
return -3;
}
tempRead = sceIoRead(tempSrc, tempData, 1024);
}
sceIoClose(tempDest);
sceIoClose(tempSrc);
return 1;
}
Example
Code: Select all
fileCopy("ms0:/PSP/GAME/File.no", "ms0:/PSP/File.no");
-
- Posts: 18
- Joined: Thu Jul 26, 2007 9:02 pm