 |
forums.ps2dev.org Homebrew PS2, PSP & PS3 Development Discussions
|
| View previous topic :: View next topic |
| Author |
Message |
Question_dev
Joined: 24 Aug 2007 Posts: 88
|
Posted: Mon Oct 01, 2007 3:45 am Post subject: Help to copy file |
|
|
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 ! |
|
| Back to top |
|
 |
TyRaNiD
Joined: 18 Jan 2004 Posts: 918
|
Posted: Mon Oct 01, 2007 4:13 am Post subject: |
|
|
*gets out C book*
Well making a directory you can do, mkdir(dir, 0777);
And copying do (minus any sort of error handling):
| Code: |
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); |
Really you should learn basic C libraries first :) |
|
| Back to top |
|
 |
Question_dev
Joined: 24 Aug 2007 Posts: 88
|
Posted: Mon Oct 01, 2007 4:15 am Post subject: |
|
|
Can i also use this :
| Code: | 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;
} |
and to copy then :
Example
| Code: | | fileCopy("ms0:/PSP/GAME/File.no", "ms0:/PSP/File.no"); |
EDIT : Yes i've tested it and it works! |
|
| Back to top |
|
 |
2.6,CRACKED!
Joined: 26 Jul 2007 Posts: 18
|
Posted: Tue Oct 02, 2007 2:14 am Post subject: |
|
|
| Then why ask in the first place, especially if your copying and pasting |
|
| 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
|